| 1 | module cli |
| 2 | |
| 3 | fn test_manpage() { |
| 4 | mut cmd := Command{ |
| 5 | name: 'command' |
| 6 | description: 'description' |
| 7 | commands: [ |
| 8 | Command{ |
| 9 | name: 'sub' |
| 10 | description: 'subcommand' |
| 11 | }, |
| 12 | Command{ |
| 13 | name: 'sub2' |
| 14 | description: 'another subcommand' |
| 15 | }, |
| 16 | ] |
| 17 | flags: [ |
| 18 | Flag{ |
| 19 | flag: .string |
| 20 | name: 'str' |
| 21 | description: 'str flag' |
| 22 | }, |
| 23 | Flag{ |
| 24 | flag: .bool |
| 25 | name: 'bool' |
| 26 | description: 'bool flag' |
| 27 | abbrev: 'b' |
| 28 | }, |
| 29 | Flag{ |
| 30 | flag: .string |
| 31 | name: 'required' |
| 32 | abbrev: 'r' |
| 33 | required: true |
| 34 | }, |
| 35 | ] |
| 36 | } |
| 37 | cmd.setup() |
| 38 | assert cmd.manpage().after_char(`\n`) == r'.Dt COMMAND 1 |
| 39 | .Os |
| 40 | .Sh NAME |
| 41 | .Nm command |
| 42 | .Nd description |
| 43 | .Sh SYNOPSIS |
| 44 | .Nm command |
| 45 | .Op Fl str Ar string |
| 46 | .Op Fl b |
| 47 | .Op Fl r Ar string |
| 48 | .Nm command |
| 49 | .Ar subcommand |
| 50 | .Sh DESCRIPTION |
| 51 | description |
| 52 | .Pp |
| 53 | The options are as follows: |
| 54 | .Bl -tag -width indent |
| 55 | .It Fl str |
| 56 | str flag |
| 57 | .It Fl b Fl bool |
| 58 | bool flag |
| 59 | .It Fl r Fl required |
| 60 | .El |
| 61 | .Pp |
| 62 | The subcommands are as follows: |
| 63 | .Bl -tag -width indent |
| 64 | .It Cm sub |
| 65 | subcommand |
| 66 | .It Cm sub2 |
| 67 | another subcommand |
| 68 | .El |
| 69 | .Sh SEE ALSO |
| 70 | .Xr command-sub 1 , |
| 71 | .Xr command-sub2 1 |
| 72 | ' |
| 73 | |
| 74 | cmd.posix_mode = true |
| 75 | assert cmd.manpage().after_char(`\n`) == r'.Dt COMMAND 1 |
| 76 | .Os |
| 77 | .Sh NAME |
| 78 | .Nm command |
| 79 | .Nd description |
| 80 | .Sh SYNOPSIS |
| 81 | .Nm command |
| 82 | .Op Fl -str Ar string |
| 83 | .Op Fl b |
| 84 | .Op Fl r Ar string |
| 85 | .Nm command |
| 86 | .Ar subcommand |
| 87 | .Sh DESCRIPTION |
| 88 | description |
| 89 | .Pp |
| 90 | The options are as follows: |
| 91 | .Bl -tag -width indent |
| 92 | .It Fl -str |
| 93 | str flag |
| 94 | .It Fl b Fl -bool |
| 95 | bool flag |
| 96 | .It Fl r Fl -required |
| 97 | .El |
| 98 | .Pp |
| 99 | The subcommands are as follows: |
| 100 | .Bl -tag -width indent |
| 101 | .It Cm sub |
| 102 | subcommand |
| 103 | .It Cm sub2 |
| 104 | another subcommand |
| 105 | .El |
| 106 | .Sh SEE ALSO |
| 107 | .Xr command-sub 1 , |
| 108 | .Xr command-sub2 1 |
| 109 | ' |
| 110 | } |
| 111 | |