|
9 | 9 | from cfengine_cli.format import format_paths |
10 | 10 | from cfengine_cli.utils import UserError |
11 | 11 | from cfengine_cli.up import validate_config, up_do, resolve_templates |
| 12 | +from cfengine_cli.initialize_project import init_policy_module, init_promise_type |
12 | 13 | from cf_remote.paths import cf_remote_dir |
| 14 | +from cfbs.commands import init_command |
13 | 15 | from pydantic import ValidationError |
14 | 16 |
|
15 | 17 |
|
@@ -49,6 +51,26 @@ def dev(subcommand, args) -> int: |
49 | 51 | return dispatch_dev_subcommand(subcommand, args) |
50 | 52 |
|
51 | 53 |
|
| 54 | +def init(args): |
| 55 | + if args.with_input and not args.policy_module: |
| 56 | + raise UserError("--with-input can only be used together with --policy-module") |
| 57 | + |
| 58 | + if args.policy_module: |
| 59 | + rc = init_policy_module( |
| 60 | + name=None, |
| 61 | + with_input=args.with_input, |
| 62 | + non_interactive=args.non_interactive, |
| 63 | + ) |
| 64 | + format(names=[], line_length=80, check=False) |
| 65 | + return rc |
| 66 | + if args.promise_type: |
| 67 | + rc = init_promise_type(name=None) |
| 68 | + format(names=[], line_length=80, check=False) |
| 69 | + return rc |
| 70 | + |
| 71 | + return init_command() # --policy-set, cfbs init, default |
| 72 | + |
| 73 | + |
52 | 74 | def profile(args) -> int: |
53 | 75 | data = None |
54 | 76 | with open(args.profiling_input, "r") as f: |
|
0 commit comments