... |
... |
@@ -713,10 +713,12 @@ def workspace_open(app, no_checkout, force, track_, element, directory): |
713
|
713
|
help="Remove the path that contains the closed workspace")
|
714
|
714
|
@click.option('--all', '-a', 'all_', default=False, is_flag=True,
|
715
|
715
|
help="Close all open workspaces")
|
|
716
|
+@click.option('--assume-yes', '-y', default=False, is_flag=True,
|
|
717
|
+ help="Assume 'yes' to confirmation of destructive changes")
|
716
|
718
|
@click.argument('elements', nargs=-1,
|
717
|
719
|
type=click.Path(readable=False))
|
718
|
720
|
@click.pass_obj
|
719
|
|
-def workspace_close(app, remove_dir, all_, elements):
|
|
721
|
+def workspace_close(app, remove_dir, all_, assume_yes, elements):
|
720
|
722
|
"""Close a workspace"""
|
721
|
723
|
|
722
|
724
|
if not (all_ or elements):
|
... |
... |
@@ -743,9 +745,15 @@ def workspace_close(app, remove_dir, all_, elements): |
743
|
745
|
if nonexisting:
|
744
|
746
|
raise AppError("Workspace does not exist", detail="\n".join(nonexisting))
|
745
|
747
|
|
746
|
|
- if app.interactive and remove_dir and app.context.prompt_workspace_close_remove_dir:
|
747
|
|
- if not click.confirm('This will remove all your changes, are you sure?'):
|
748
|
|
- click.echo('Aborting', err=True)
|
|
748
|
+ if remove_dir and not assume_yes and app.context.prompt_workspace_close_remove_dir:
|
|
749
|
+ if app.interactive:
|
|
750
|
+ if not click.confirm('This will remove all your changes, are you sure?'):
|
|
751
|
+ click.echo('Aborting', err=True)
|
|
752
|
+ sys.exit(-1)
|
|
753
|
+ else:
|
|
754
|
+ click.echo(
|
|
755
|
+ "Aborting since non-interactive and destructive action requested.", err=True)
|
|
756
|
+ click.echo("Please use the '--assume-yes' option to override.", err=True)
|
749
|
757
|
sys.exit(-1)
|
750
|
758
|
|
751
|
759
|
for element_name in elements:
|
... |
... |
@@ -762,10 +770,12 @@ def workspace_close(app, remove_dir, all_, elements): |
762
|
770
|
help="Track and fetch the latest source before resetting")
|
763
|
771
|
@click.option('--all', '-a', 'all_', default=False, is_flag=True,
|
764
|
772
|
help="Reset all open workspaces")
|
|
773
|
+@click.option('--assume-yes', '-y', default=False, is_flag=True,
|
|
774
|
+ help="Assume 'yes' to confirmation of destructive changes")
|
765
|
775
|
@click.argument('elements', nargs=-1,
|
766
|
776
|
type=click.Path(readable=False))
|
767
|
777
|
@click.pass_obj
|
768
|
|
-def workspace_reset(app, soft, track_, all_, elements):
|
|
778
|
+def workspace_reset(app, soft, track_, all_, assume_yes, elements):
|
769
|
779
|
"""Reset a workspace to its original state"""
|
770
|
780
|
|
771
|
781
|
# Check that the workspaces in question exist
|
... |
... |
@@ -777,9 +787,15 @@ def workspace_reset(app, soft, track_, all_, elements): |
777
|
787
|
if all_ and not app.stream.workspace_exists():
|
778
|
788
|
raise AppError("No open workspaces to reset")
|
779
|
789
|
|
780
|
|
- if app.interactive and not soft and app.context.prompt_workspace_reset_hard:
|
781
|
|
- if not click.confirm('This will remove all your changes, are you sure?'):
|
782
|
|
- click.echo('Aborting', err=True)
|
|
790
|
+ if not soft and not assume_yes and app.context.prompt_workspace_reset_hard:
|
|
791
|
+ if app.interactive:
|
|
792
|
+ if not click.confirm('This will remove all your changes, are you sure?'):
|
|
793
|
+ click.echo('Aborting', err=True)
|
|
794
|
+ sys.exit(-1)
|
|
795
|
+ else:
|
|
796
|
+ click.echo(
|
|
797
|
+ "Aborting since non-interactive and destructive action requested.", err=True)
|
|
798
|
+ click.echo("Please use the '--assume-yes' option to override.", err=True)
|
783
|
799
|
sys.exit(-1)
|
784
|
800
|
|
785
|
801
|
if all_:
|