-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e607d2
commit 64ce8c6
Showing
3 changed files
with
78 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
import sys | ||
from option import Option | ||
|
||
""" | ||
Generate options for man | ||
""" | ||
from typing import * | ||
import sys | ||
|
||
|
||
def generate_man(options: List[Option]): | ||
s = "" | ||
for option in options: | ||
if not option.deprecated: | ||
s += generate_man_option(option) | ||
s += "\n\n" | ||
return s | ||
|
||
|
||
def generate_man_option(option: Option): | ||
s = "###" | ||
if option.short: | ||
s += " -%s," % option.short | ||
s += " --%s" % option.long | ||
if option.value: | ||
s += " <%s>" % option.value | ||
s += " {#%s}" % option.long.replace(".", "") | ||
s += "\n\n" | ||
s += option.description | ||
return s | ||
|
||
|
||
def main(): | ||
# Parse all options file given at the command line | ||
if len(sys.argv) < 2: | ||
print("usage: generate_nab.py OPTION_FILE1 OPTION_FILE2 ...") | ||
sys.exit(1) | ||
options = sorted( | ||
[Option.parse_file(filename) for filename in sys.argv[1:]], | ||
key=lambda option: option.long, | ||
) | ||
print(generate_man(options)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Format all option files | ||
bin/spec/cmdline-opts/format.py docs/spec/cmdline-opts-hurl/*.option | ||
|
||
# Generate/Update clap command source file | ||
bin/spec/cmdline-opts/generate_source.py docs/spec/cmdline-opts-hurl/*.option >packages/hurl/src/cli/options/commands.rs | ||
|
||
# Generate/Update man options | ||
bin/spec/cmdline-opts/generate_man.py docs/spec/cmdline-opts-hurl/*.option |