Skip to content

Commit 61b6fc5

Browse files
committed
Improve docs of nixops eval
1 parent ffd40d6 commit 61b6fc5

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

nixops/__main__.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -528,14 +528,20 @@
528528
)
529529

530530
subparser = add_subparser(
531-
subparsers, "eval", help="eval the given file is nix code in the network expression"
531+
subparsers,
532+
"eval",
533+
help="evaluate a Nix expression with the NixOps network as arguments",
532534
)
533535
subparser.set_defaults(op=op_eval)
534-
subparser.add_argument("code", metavar="CODE", help="code")
536+
subparser.add_argument("file", metavar="FILE", help="file containing a Nix expression")
535537
subparser.add_argument(
536-
"--json", action="store_true", help="print the option value in JSON format"
538+
"--json", action="store_true", help="convert and print the return value as JSON"
539+
)
540+
subparser.add_argument(
541+
"--strict",
542+
action="store_true",
543+
help="enable strict evaluation, (use with --json if value is more than a level deep)",
537544
)
538-
subparser.add_argument("--strict", action="store_true", help="enable strict evaluation")
539545

540546
subparser = add_subparser(
541547
subparsers,

nixops/deployment.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ def evaluate(self) -> None:
503503
)
504504
self.definitions[name] = defn
505505

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

509509
exprs = self.nix_exprs
@@ -524,7 +524,7 @@ def evaluate_code(self, code: str, json: bool = False, strict: bool = False) ->
524524
"false",
525525
"--arg",
526526
"evalFile",
527-
code,
527+
file,
528528
]
529529
+ (["--strict"] if strict else [])
530530
+ (["--json"] if json else []),

nixops/script_defs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ def op_eval(args):
897897
with deployment(args) as depl:
898898
depl.evaluate()
899899
sys.stdout.write(
900-
depl.evaluate_code(args.code, json=args.json, strict=args.strict)
900+
depl.evaluate_code(args.file, json=args.json, strict=args.strict)
901901
)
902902

903903

0 commit comments

Comments
 (0)