Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Use Python's argparse module in shell scripts

The function ``argparse`` parses its arguments using
``argparse.ArgumentParser``. The command line options are defined in
the function's stdin. ``argparse.bash`` should be in the same
directory as a script that uses it.
the function's stdin. ``argparse.bash`` should be on the $PATH or in
the current directory.

Python 2.7 or 3.5+ is required. See
https://docs.python.org/2.7/library/argparse.html for a description of
Expand All @@ -28,7 +28,7 @@ Get ``argparse.bash``
wget https://raw.githubusercontent.com/nhoffman/argparse-bash/master/argparse.bash
chmod +x argparse.bash

Then move the file into the same directory as any scripts that will use it.
Then move the file into a directory that is on your $PATH (/usr/local/bin or $HOME/bin).

Alternatively, you can paste the body of the ``argparse()`` function
into your script (in which case you would of course omit the line
Expand All @@ -45,7 +45,7 @@ Here's an example, ``example.sh``
#!/usr/bin/env bash

ARGPARSE_DESCRIPTION="Sample script description" # this is optional
source $(dirname $0)/argparse.bash || exit 1
source argparse.bash || exit 1
argparse "$@" <<EOF || exit 1
parser.add_argument('infile')
parser.add_argument('outfile')
Expand Down Expand Up @@ -123,7 +123,7 @@ script template to stdout
$ ./argparse.bash
#!/usr/bin/env bash

source $(dirname $0)/argparse.bash || exit 1
source argparse.bash || exit 1
argparse "$@" <<EOF || exit 1
parser.add_argument('infile')
parser.add_argument('-o', '--outfile')
Expand Down
2 changes: 1 addition & 1 deletion argparse.bash
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if [[ $0 == *argparse.bash ]]; then
cat <<FOO
#!/usr/bin/env bash

source \$(dirname \$0)/argparse.bash || exit 1
source argparse.bash || exit 1
argparse "\$@" <<EOF || exit 1
parser.add_argument('infile')
parser.add_argument('-o', '--outfile')
Expand Down
2 changes: 1 addition & 1 deletion example.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

ARGPARSE_DESCRIPTION="Sample script description" # this is optional
source $(dirname $0)/argparse.bash || exit 1
source argparse.bash || exit 1
argparse "$@" <<EOF || exit 1
parser.add_argument('infile')
parser.add_argument('outfile')
Expand Down