Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with @syntax #1581

Merged
merged 2 commits into from
Dec 15, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/azure-cli-core/azure/cli/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,13 +202,15 @@ def _register_builtin_arguments(**kwargs):
@staticmethod
def _maybe_load_file(arg):
ix = arg.find('@')
if ix == -1:
if ix == -1: # not found
return arg

if ix == len(arg) - 1: # allow simply the value '@' (used by DNS for example)
return arg

if ix == 0:
return Application._load_file(arg[1:])

if arg[ix - 1] == '=':
elif arg[ix - 1] == '=':
return arg[:ix] + Application._load_file(arg[ix + 1:])

return arg
Expand All @@ -225,7 +227,7 @@ def _load_file(path):
if path == '-':
content = sys.stdin.read()
else:
with open(path, 'r') as input_file:
with open(os.path.expanduser(path), 'r') as input_file:
content = input_file.read()

return content[0:-1] if content[-1] == '\n' else content
Expand Down