Closed tanelpoder closed 5 years ago
This is not going to save you from having to use argparse. Just something to think about. As the program grows the option list could get very long. Personally I have moved away from having too many command line arguments and moved to functions which set state explicitly before running main command. I find this more readable and easier to manage.
So instead of
foo -x -d "bar" -z 45..............................
I might have
foo_set_export true foo_set_key "bar" foo_set_zulu 45 foo -with_a -couple_main_args...
This is just an example I throw out there, not 100% correct, but you get the idea. Usually the ones you set this way are not ones you are going to touch a lot.
The goal is not to avoid using the argparse library, but to avoid users having to install newer python (or pip install argparse) into their production systems. Reduce friction as much as possible. Bundling argparse.py with psnapper itself achieves that goal.
Yeah, regarding having too many command line options, I hear you. That's why I'm trying to have sensible defaults for some things (simple stuff, like sampling for 5 seconds if -d
option is not specified and have a default field grouping too - perhaps different when looking into the whole system vs zooming in to a single process/thread).
And I'm thinking of introducing some "what do you want to do" templates... for example perf
has multiple modes like perf top
, perf stat
, perf sched
etc ... perhaps there should also be things like psn top
, psn kernel
, psn syscalls
in addition to some default behavior of just running psn
without any arguments. v1.0 stuff! :-)
argparse.py bundled in the repo.
This is needed for older python versions where argparse is not bundled by default.
Apparenlty it's tested even on python 2.3 so can be safely bundled for convenience.
https://pypi.org/project/argparse/