Skip to content

Commit 702c116

Browse files
authored
expand usage section of README (#116)
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
1 parent ffd3818 commit 702c116

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,23 @@ A `Python` command line client for [tldr](https://github.com/tldr-pages/tldr).
2323

2424
## Usage
2525

26-
tldr <command>
26+
usage: tldr [-u] [-p PLATFORM] [-s SOURCE] [-c] [-r] [-L LANGUAGE] command
27+
28+
Python command line client for tldr
29+
30+
optional arguments:
31+
-h, --help show this help message and exit
32+
-v, --version show program's version number and exit
33+
-u, --update_cache Update the local cache of pages and exit
34+
-p PLATFORM, --platform PLATFORM
35+
Override the operating system [linux, osx, sunos,
36+
windows, common]
37+
-s SOURCE, --source SOURCE
38+
Override the default page source
39+
-c, --color Override color stripping
40+
-r, --render Render local markdown files
41+
-L LANGUAGE, --language LANGUAGE
42+
Override the default language
2743

2844
## Configuration
2945

tldr.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ def update_cache(language=None):
310310
def main():
311311
parser = ArgumentParser(
312312
prog="tldr",
313+
usage="tldr [-u] [-p PLATFORM] [-s SOURCE] [-c] [-r] [-L LANGUAGE] " +
314+
"command",
313315
description="Python command line client for tldr"
314316
)
315317
parser.add_argument(
@@ -358,32 +360,29 @@ def main():
358360
type=str,
359361
help='Override the default language')
360362

361-
options, rest = parser.parse_known_args()
363+
parser.add_argument(
364+
'command', type=str, nargs='*', help="command to lookup"
365+
)
366+
367+
options = parser.parse_args()
362368

363369
colorama.init(strip=options.color)
364370

365371
if options.update_cache:
366372
update_cache(language=options.language)
367373
return
368-
369-
parser.add_argument(
370-
'command', type=str, nargs='+', help="command to lookup"
371-
)
372-
373-
if len(sys.argv) == 1:
374+
elif len(sys.argv) == 1:
374375
parser.print_help(sys.stderr)
375376
sys.exit(1)
376377

377-
rest = parser.parse_args(rest)
378-
379378
if options.render:
380-
for command in rest.command:
379+
for command in options.command:
381380
if os.path.exists(command):
382381
with open(command, encoding='utf-8') as open_file:
383382
output(open_file.read().encode('utf-8').splitlines())
384383
else:
385384
try:
386-
command = '-'.join(rest.command)
385+
command = '-'.join(options.command)
387386
result = get_page(
388387
command,
389388
options.source,

0 commit comments

Comments
 (0)