nhoffman / argparse-bash Goto Github PK
View Code? Open in Web Editor NEWUse python's argparse module in shell scripts
License: MIT License
Use python's argparse module in shell scripts
License: MIT License
If action='store_true' is set, then the variable starts True
or False
strings, might be a better way to do this.
Since calling python my_script.py --help
return an exit code of 0, shouldn't calling bash my_script.sh --help
also return an exit code of 0. Currently, it is documented in the project that an exit of code of 1 will be returned, but I think it should be 0 based on this.
Hi
I'm trying to run the example.sh script: bash /home/alu/ekushele/script/bash/conf.sh
I'm getting an error:
/home/alu/ekushele/script/bash/conf.sh: line 28: warning: here-document at line 4 delimited by end-of-file (wanted `EOF')
File "/tmp/tmp.hl53hz9h93", line 25
echo required infile: ""
^
SyntaxError: invalid syntax
: numeric argument requiredash/conf.sh: line 4: exit: 1
What can I do?
Cool code - What's the license on this?
The proper thing to do would be to abandon *sh altogether, and instead use a scripting language with a proper library for defining a command line interface. Can anyone think of one?
I think that Xonsh (http://xon.sh/) might be able to do that.
Due to 0 being falsy, this code fails to parse an int argument of 0
https://github.com/nhoffman/argparse-bash/blob/master/argparse.bash#L39
for arg in [a for a in dir(args) if not a.startswith('_')]:
print('{}="{}";'.format(arg.upper(), getattr(args, arg) or ''))
When I run my bash script with the version argument, e.g.
parser.add_argument('--version', action='version', version='%(prog)s 1.0.0')
I get the following error:
./argparse.bash: line 60: 0.1: command not found
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.