-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle hex values, fix bugs when positional arg is a float/int
- Loading branch information
1 parent
0f88851
commit c14307c
Showing
6 changed files
with
71 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
duckargs -f --fff 0xabc -q 0x --test ox2 |
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,19 @@ | ||
# -f --fff 0xabc -q 0x --test ox2 | ||
|
||
import argparse | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='A command-line program generated by duckargs', | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
|
||
parser.add_argument('-f', '--fff', default=0xabc, type=int, help='an int value') | ||
parser.add_argument('-q', default='0x', help='a string') | ||
parser.add_argument('--test', default='ox2', help='a string') | ||
args = parser.parse_args() | ||
|
||
print(args.fff) | ||
print(args.q) | ||
print(args.test) | ||
|
||
if __name__ == "__main__": | ||
main() |
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 @@ | ||
duckargs 0x 0x123 2.3 hello -r --ra FILE |
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,23 @@ | ||
# 0x 0x123 2.3 hello -r --ra FILE | ||
|
||
import argparse | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='A command-line program generated by duckargs', | ||
formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
|
||
parser.add_argument('positional_arg0', help='a string') | ||
parser.add_argument('positional_arg1', type=int, help='an int value') | ||
parser.add_argument('positional_arg2', type=float, help='a float value') | ||
parser.add_argument('hello', help='a string') | ||
parser.add_argument('-r', '--ra', default=None, type=argparse.FileType(), help='a filename') | ||
args = parser.parse_args() | ||
|
||
print(args.positional_arg0) | ||
print(args.positional_arg1) | ||
print(args.positional_arg2) | ||
print(args.hello) | ||
print(args.ra) | ||
|
||
if __name__ == "__main__": | ||
main() |
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