|
7 | 7 | #from .config import compute_operations, Config |
8 | 8 | from dotter.model import (ConfigCategory, ConfigLinkMode, ConfigPatternSetting, |
9 | 9 | DotterRepo) |
10 | | -from dotter.sync_plan import LogicalSyncPlan, PhysicalSyncPlan, compute_topic_operations |
| 10 | +from dotter.sync_plan import SyncError, LogicalSyncPlan, PhysicalSyncPlan, compute_topic_operations |
11 | 11 |
|
12 | 12 | __version__ = importlib.metadata.version('nl-dotter') |
13 | 13 |
|
@@ -50,8 +50,11 @@ def __op_report(plan: PhysicalSyncPlan, needs_force: bool): |
50 | 50 | arrow = "<-" |
51 | 51 | plan_s = f"[{plan.type}:{plan.action}] {plan.src_path} {arrow} {plan.dst_path}" |
52 | 52 |
|
| 53 | + msg = f"? {plan_s}" |
53 | 54 | if needs_force: |
54 | 55 | msg = click.style(f"! {plan_s} (needs force)", fg='red') |
| 56 | + elif plan.action == 'replace': |
| 57 | + msg = click.style(f"! {plan_s} (forced)", fg='yellow') |
55 | 58 | elif plan.action == 'remove': |
56 | 59 | msg = click.style(f"- {plan_s}", fg='red') |
57 | 60 | elif plan.action in ['create'] or plan.type == ['touch']: |
@@ -79,7 +82,10 @@ def __sop_repot(plan: LogicalSyncPlan): |
79 | 82 | for op in topic_plan: |
80 | 83 | __sop_repot(op) |
81 | 84 | for plan in op.reconcile(): |
82 | | - plan.apply(force=force, backup=True, dry_run=dry_run, report=__op_report) |
| 85 | + try: |
| 86 | + plan.apply(force=force, backup=True, dry_run=dry_run, report=__op_report) |
| 87 | + except SyncError as err: |
| 88 | + raise click.ClickException(str(err)) |
83 | 89 |
|
84 | 90 | @main.command(name='version', short_help="show version") |
85 | 91 | def main_version(): |
|
0 commit comments