@@ -236,6 +236,55 @@ func TestRunWithInsufficientArgs(t *testing.T) {
236236 }
237237}
238238
239+ // TestRunWithHelpFlags tests the run function with help flag arguments.
240+ func TestRunWithHelpFlags (t * testing.T ) {
241+ helpFlags := []string {"--help" , "-h" , "help" }
242+
243+ for _ , flag := range helpFlags {
244+ t .Run ("help_flag_" + flag , func (t * testing.T ) {
245+ // Capture stdout
246+ oldStdout := os .Stdout
247+ r , w , _ := os .Pipe ()
248+ os .Stdout = w
249+
250+ // Run with help flag
251+ args := []string {"articulate-parser" , flag }
252+ exitCode := run (args )
253+
254+ // Restore stdout
255+ w .Close ()
256+ os .Stdout = oldStdout
257+
258+ // Read captured output
259+ var buf bytes.Buffer
260+ io .Copy (& buf , r )
261+ output := buf .String ()
262+
263+ // Verify exit code is 0 (success)
264+ if exitCode != 0 {
265+ t .Errorf ("Expected exit code 0 for help flag %s, got %d" , flag , exitCode )
266+ }
267+
268+ // Verify help content is displayed
269+ expectedContent := []string {
270+ "Usage:" ,
271+ "source: URI or file path to the course" ,
272+ "format: export format" ,
273+ "output: output file path" ,
274+ "Example:" ,
275+ "articulate-sample.json markdown output.md" ,
276+ "https://rise.articulate.com/share/xyz docx output.docx" ,
277+ }
278+
279+ for _ , expected := range expectedContent {
280+ if ! strings .Contains (output , expected ) {
281+ t .Errorf ("Expected help output to contain %q when using flag %s, got: %s" , expected , flag , output )
282+ }
283+ }
284+ })
285+ }
286+ }
287+
239288// TestRunWithInvalidFile tests the run function with a non-existent file.
240289func TestRunWithInvalidFile (t * testing.T ) {
241290 // Capture stdout and stderr
0 commit comments