| 541 | } |
| 542 | |
| 543 | func ExampleCommand_Suggest() { |
| 544 | cmd := &cli.Command{ |
| 545 | Name: "greet", |
| 546 | ErrWriter: os.Stdout, |
| 547 | Suggest: true, |
| 548 | HideHelp: false, |
| 549 | HideHelpCommand: true, |
| 550 | CustomRootCommandHelpTemplate: "(this space intentionally left blank)\n", |
| 551 | Flags: []cli.Flag{ |
| 552 | &cli.StringFlag{Name: "name", Value: "squirrel", Usage: "a name to say"}, |
| 553 | }, |
| 554 | Action: func(_ context.Context, cmd *cli.Command) error { |
| 555 | fmt.Printf("Hello %v\n", cmd.String("name")) |
| 556 | return nil |
| 557 | }, |
| 558 | } |
| 559 | |
| 560 | if cmd.Run(context.Background(), []string{"greet", "--nema", "chipmunk"}) == nil { |
| 561 | fmt.Println("Expected error") |
| 562 | } |
| 563 | // Output: |
| 564 | // Incorrect Usage: flag provided but not defined: -nema |
| 565 | // |
| 566 | // Did you mean "--name"? |
| 567 | // |
| 568 | // (this space intentionally left blank) |
| 569 | } |
| 570 | |
| 571 | func ExampleCommand_Suggest_command() { |
| 572 | cmd := &cli.Command{ |