Skip to content

Commit

Permalink
added shell args for FOO=bar format
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Burón committed Mar 5, 2015
1 parent ca9c69c commit 0768eb3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dotenv/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,21 @@

parser.add_argument('--version', action='version', version=__version__)

parser.add_argument('--shell', action='store_true', default=False)

args = parser.parse_args()


if args.shell:
PRINT_FORMAT = '%s=%s'
else:
PRINT_FORMAT = '%s: %s'

if args.key is None:
for key, value in get_variables(args.file).items():
print("%s: %s" % (key, value))
print(PRINT_FORMAT % (key, value))
elif args.value is None:
print("%s: %s" % (args.key, get_variable(args.file, args.key)))
print(PRINT_FORMAT % (args.key, get_variable(args.file, args.key)))
else:
set_variable(args.file, args.key, args.value)
print("%s: %s" % (args.key, args.value))
print(PRINT_FORMAT % (args.key, args.value))

0 comments on commit 0768eb3

Please sign in to comment.