-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from krysopath/3-cli-functions
add some very basic cli code
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
|
||
import argparse | ||
import sys | ||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument( | ||
"action", default="run" | ||
) | ||
|
||
parser.add_argument( | ||
"-v", "--verbosity", | ||
type=str, | ||
default='WARN', | ||
choices=['DEBUG', 'INFO', 'WARN', 'CRIT'], | ||
help="set logging verbosity" | ||
) | ||
|
||
parser.add_argument( | ||
'-c', '--config', | ||
type=argparse.FileType('r'), | ||
default=sys.stdin, | ||
help="specify a configuration file to override defaults, if not specified, STDIN will be used" | ||
) | ||
|
||
args = parser.parse_args() | ||
print(args) | ||
inp = args.config.read() | ||
if inp: | ||
print(inp) |