Angelos Evripiotis pushed to branch aevri/prompt-config at BuildStream / buildstream
Commits:
-
5081fa6f
by Angelos Evripiotis at 2018-10-19T18:04:55Z
-
8d6f82b5
by Angelos Evripiotis at 2018-10-19T21:11:28Z
-
9452c346
by Angelos Evripiotis at 2018-10-19T21:12:12Z
5 changed files:
- NEWS
- buildstream/_context.py
- buildstream/_frontend/app.py
- buildstream/_frontend/cli.py
- buildstream/data/userconfig.yaml
Changes:
... | ... | @@ -31,6 +31,12 @@ buildstream 1.3.1 |
31 | 31 |
new the `conf-root` variable to make the process easier. And there has been
|
32 | 32 |
a bug fix to workspaces so they can be build in workspaces too.
|
33 | 33 |
|
34 |
+ o The buildstream.conf file learned new 'prompt.auto-init',
|
|
35 |
+ 'prompt.workspace-close-remove-dir', and 'prompt.workspace-reset-hard'
|
|
36 |
+ options. These allow users to suppress certain confirmation prompts, e.g.
|
|
37 |
+ double-checking that the user meant to run the command as typed.
|
|
38 |
+ |
|
39 |
+ |
|
34 | 40 |
=================
|
35 | 41 |
buildstream 1.1.5
|
36 | 42 |
=================
|
... | ... | @@ -104,6 +104,18 @@ class Context(): |
104 | 104 |
# What to do when a build fails in non interactive mode
|
105 | 105 |
self.sched_error_action = 'continue'
|
106 | 106 |
|
107 |
+ # Whether to offer to create a project for the user, if we are invoked
|
|
108 |
+ # outside of a directory where we can resolve the project.
|
|
109 |
+ self.prompt_auto_init = True
|
|
110 |
+ |
|
111 |
+ # Whether we double-check with the user that they meant to remove a
|
|
112 |
+ # workspace directory.
|
|
113 |
+ self.prompt_workspace_close_remove_dir = True
|
|
114 |
+ |
|
115 |
+ # Whether we double-check with the user that they meant to do a hard
|
|
116 |
+ # reset of a workspace, potentially losing changes.
|
|
117 |
+ self.prompt_workspace_reset_hard = True
|
|
118 |
+ |
|
107 | 119 |
# Whether elements must be rebuilt when their dependencies have changed
|
108 | 120 |
self._strict_build_plan = None
|
109 | 121 |
|
... | ... | @@ -160,7 +172,7 @@ class Context(): |
160 | 172 |
_yaml.node_validate(defaults, [
|
161 | 173 |
'sourcedir', 'builddir', 'artifactdir', 'logdir',
|
162 | 174 |
'scheduler', 'artifacts', 'logging', 'projects',
|
163 |
- 'cache'
|
|
175 |
+ 'cache', 'prompt'
|
|
164 | 176 |
])
|
165 | 177 |
|
166 | 178 |
for directory in ['sourcedir', 'builddir', 'artifactdir', 'logdir']:
|
... | ... | @@ -212,6 +224,19 @@ class Context(): |
212 | 224 |
self.sched_pushers = _yaml.node_get(scheduler, int, 'pushers')
|
213 | 225 |
self.sched_network_retries = _yaml.node_get(scheduler, int, 'network-retries')
|
214 | 226 |
|
227 |
+ # Load prompt preferences
|
|
228 |
+ prompt = _yaml.node_get(
|
|
229 |
+ defaults, Mapping, 'prompt')
|
|
230 |
+ _yaml.node_validate(prompt, [
|
|
231 |
+ 'auto-init', 'workspace-close-remove-dir', 'workspace-reset-hard',
|
|
232 |
+ ])
|
|
233 |
+ self.prompt_auto_init = _yaml.node_get(
|
|
234 |
+ prompt, bool, 'auto-init')
|
|
235 |
+ self.prompt_workspace_close_remove_dir = _yaml.node_get(
|
|
236 |
+ prompt, bool, 'workspace-close-remove-dir')
|
|
237 |
+ self.prompt_workspace_reset_hard = _yaml.node_get(
|
|
238 |
+ prompt, bool, 'workspace-reset-hard')
|
|
239 |
+ |
|
215 | 240 |
# Load per-projects overrides
|
216 | 241 |
self._project_overrides = _yaml.node_get(defaults, Mapping, 'projects', default_value={})
|
217 | 242 |
|
... | ... | @@ -222,9 +222,10 @@ class App(): |
222 | 222 |
# Let's automatically start a `bst init` session in this case
|
223 | 223 |
if e.reason == LoadErrorReason.MISSING_PROJECT_CONF and self.interactive:
|
224 | 224 |
click.echo("A project was not detected in the directory: {}".format(directory), err=True)
|
225 |
- click.echo("", err=True)
|
|
226 |
- if click.confirm("Would you like to create a new project here ?"):
|
|
227 |
- self.init_project(None)
|
|
225 |
+ if self.context.prompt_auto_init:
|
|
226 |
+ click.echo("", err=True)
|
|
227 |
+ if click.confirm("Would you like to create a new project here?"):
|
|
228 |
+ self.init_project(None)
|
|
228 | 229 |
|
229 | 230 |
self._error_exit(e, "Error loading project")
|
230 | 231 |
|
... | ... | @@ -743,7 +743,7 @@ def workspace_close(app, remove_dir, all_, elements): |
743 | 743 |
if nonexisting:
|
744 | 744 |
raise AppError("Workspace does not exist", detail="\n".join(nonexisting))
|
745 | 745 |
|
746 |
- if app.interactive and remove_dir:
|
|
746 |
+ if app.interactive and remove_dir and app.context.prompt_workspace_close_remove_dir:
|
|
747 | 747 |
if not click.confirm('This will remove all your changes, are you sure?'):
|
748 | 748 |
click.echo('Aborting', err=True)
|
749 | 749 |
sys.exit(-1)
|
... | ... | @@ -777,7 +777,7 @@ def workspace_reset(app, soft, track_, all_, elements): |
777 | 777 |
if all_ and not app.stream.workspace_exists():
|
778 | 778 |
raise AppError("No open workspaces to reset")
|
779 | 779 |
|
780 |
- if app.interactive and not soft:
|
|
780 |
+ if app.interactive and not soft and app.context.prompt_workspace_reset_hard:
|
|
781 | 781 |
if not click.confirm('This will remove all your changes, are you sure?'):
|
782 | 782 |
click.echo('Aborting', err=True)
|
783 | 783 |
sys.exit(-1)
|
... | ... | @@ -97,3 +97,19 @@ logging: |
97 | 97 |
|
98 | 98 |
[%{elapsed}][%{key}][%{element}] %{action} %{message}
|
99 | 99 |
|
100 |
+#
|
|
101 |
+# Prompts we may present to the user
|
|
102 |
+#
|
|
103 |
+ |
|
104 |
+prompt:
|
|
105 |
+ # Whether to offer to create a project, if we are invoked outside of a
|
|
106 |
+ # directory where we can resolve the project.
|
|
107 |
+ auto-init: True
|
|
108 |
+ |
|
109 |
+ # Whether we double-check with the user that they meant to remove a
|
|
110 |
+ # workspace directory.
|
|
111 |
+ workspace-close-remove-dir: True
|
|
112 |
+ |
|
113 |
+ # Whether we double-check with the user that they meant to do a hard
|
|
114 |
+ # reset of a workspace, potentially losing changes.
|
|
115 |
+ workspace-reset-hard: True
|