Skip to content

Commit

Permalink
Improve docs of nixops eval
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Apr 27, 2020
1 parent ffd40d6 commit 50ace43
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions nixops/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,14 +528,14 @@
)

subparser = add_subparser(
subparsers, "eval", help="eval the given file is nix code in the network expression"
subparsers, "eval", help="evaluate a Nix expression with the NixOps network as arguments"
)
subparser.set_defaults(op=op_eval)
subparser.add_argument("code", metavar="CODE", help="code")
subparser.add_argument("file", metavar="FILE", help="file containing a Nix expression")
subparser.add_argument(
"--json", action="store_true", help="print the option value in JSON format"
"--json", action="store_true", help="convert and print the return value as JSON"
)
subparser.add_argument("--strict", action="store_true", help="enable strict evaluation")
subparser.add_argument("--strict", action="store_true", help="enable strict evaluation, (use with --json if value is more than a level deep)")

subparser = add_subparser(
subparsers,
Expand Down
4 changes: 2 additions & 2 deletions nixops/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ def evaluate(self) -> None:
)
self.definitions[name] = defn

def evaluate_code(self, code: str, json: bool = False, strict: bool = False) -> str:
def evaluate_code(self, file: str, json: bool = False, strict: bool = False) -> str:
"""Evaluate nix code in the deployment specification."""

exprs = self.nix_exprs
Expand All @@ -524,7 +524,7 @@ def evaluate_code(self, code: str, json: bool = False, strict: bool = False) ->
"false",
"--arg",
"evalFile",
code,
file,
]
+ (["--strict"] if strict else [])
+ (["--json"] if json else []),
Expand Down
2 changes: 1 addition & 1 deletion nixops/script_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def op_eval(args):
with deployment(args) as depl:
depl.evaluate()
sys.stdout.write(
depl.evaluate_code(args.code, json=args.json, strict=args.strict)
depl.evaluate_code(args.file, json=args.json, strict=args.strict)
)


Expand Down

0 comments on commit 50ace43

Please sign in to comment.