-
Notifications
You must be signed in to change notification settings - Fork 602
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
trying a totally different approach to displaying command line docume…
…ntation. programoutput sux
- Loading branch information
Dean Malmgren
committed
Aug 9, 2014
1 parent
dfd5ee5
commit 0fff2f6
Showing
6 changed files
with
68 additions
and
61 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
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
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 |
---|---|---|
|
@@ -9,4 +9,4 @@ pep8 | |
# for documentation | ||
sphinx | ||
sphinx_rtd_theme | ||
sphinxcontrib-programoutput | ||
sphinx-argparse |
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,38 @@ | ||
import argparse | ||
|
||
import argcomplete | ||
|
||
from . import VERSION | ||
|
||
|
||
# This function is necessary to enable autodocumentation of the script | ||
# output | ||
def get_parser(): | ||
"""Initialize the parser for the command line interface and bind the | ||
autocompletion functionality""" | ||
|
||
# initialize the parser | ||
parser = argparse.ArgumentParser( | ||
description='Command line tool for extracting text from any document' | ||
) | ||
|
||
# define the command line options here | ||
parser.add_argument( | ||
'filename', help='Filename to extract text.', | ||
).completer = argcomplete.completers.FilesCompleter | ||
parser.add_argument( | ||
'-o', '--output', type=argparse.FileType('w'), default='-', | ||
help='output raw text in this file', | ||
) | ||
parser.add_argument( | ||
'-m', '--method', default='', | ||
help='specify a method of extraction for formats that support it', | ||
) | ||
parser.add_argument( | ||
'-v', '--version', action='version', version='%(prog)s '+VERSION, | ||
) | ||
|
||
# enable autocompletion with argcomplete | ||
argcomplete.autocomplete(parser) | ||
|
||
return parser |