-
Notifications
You must be signed in to change notification settings - Fork 39
refactor(mode): replace config-based mode setting with runtime detection #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a9c1621
0ee8239
884e724
6c7e06e
58408d6
3bcad54
4a9d8d0
7a563ff
dcdec92
20aa53f
daa49eb
ef889b3
28ea374
273a7eb
e71de12
65f670f
17e174c
8da15f4
85933fe
b2d8a5b
ddb8d4a
85a46d2
dc276c9
56e5317
1aaabd5
e14ec48
01a8c61
a63b991
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| kind: optimization | ||
| body: Replace config-based mode setting with runtime detection for interactive/command-line mode | ||
| time: 2026-03-22T10:36:53.000000000Z | ||
| custom: | ||
| Author: ayeshurun | ||
| AuthorLink: https://github.com/ayeshurun |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,40 @@ | ||
| # CLI Modes | ||
|
|
||
| The Fabric CLI supports two primary modes to accommodate a variety of workflows: **command line** and **interactive**. The selected mode is preserved between sessions. If you exit and login to the CLI later, it will resume in the same mode you last used. | ||
| The Fabric CLI supports two modes: **command-line** and **REPL** (interactive). The active mode is determined automatically at runtime — no configuration is required. | ||
|
|
||
| Use the following command to see the current stored mode setting: | ||
| ## Command-Line Mode | ||
|
|
||
| ``` | ||
| fab config get mode | ||
| ``` | ||
|
|
||
| ## Command Line Mode | ||
| Command-line mode is best suited for scripted tasks, automation, or when you prefer running single commands without a persistent prompt. | ||
|
|
||
| Command line mode is best suited for scripted tasks, automation, or when you prefer running single commands without a prompt. | ||
|
|
||
| Typing commands directly in the terminal replicates typical UNIX-style usage. | ||
|
|
||
| Use the following command to switch the CLI into command line mode: | ||
| Invoke any command directly from your terminal with the `fab` prefix: | ||
|
|
||
| ``` | ||
| fab config set mode command_line | ||
| fab ls / | ||
| fab get /myworkspace.Workspace/mynotebook.Notebook | ||
| ``` | ||
|
|
||
| You will be required to log in again after switching modes. | ||
|
|
||
| ## Interactive Mode | ||
| ## REPL Mode | ||
|
|
||
| Interactive mode provides a shell-like environment in which you can run Fabric CLI commands directly without the `fab` prefix. | ||
| REPL mode provides a shell-like interactive environment. Run `fab` without any arguments to enter REPL mode: | ||
|
|
||
| Upon entering interactive mode, you see a `fab:/$` prompt. Commands are executed one by one without needing to type `fab` before each command, giving you a more guided experience. | ||
| ``` | ||
| fab | ||
| ``` | ||
|
|
||
| Use the following command to switch the CLI into interactive mode: | ||
| Upon entering REPL mode, you see a `fab:/$` prompt. Commands are executed one by one without needing to type `fab` before each command: | ||
|
|
||
| ``` | ||
| fab config set mode interactive | ||
| fab:/$ ls | ||
| fab:/$ cd myworkspace.Workspace | ||
| fab:/myworkspace.Workspace$ get mynotebook.Notebook | ||
| fab:/myworkspace.Workspace$ quit | ||
| ``` | ||
|
|
||
| You will be required to log in again after switching modes. | ||
| Type `help` for a list of available commands, and `quit` or `exit` to leave REPL mode. | ||
|
|
||
| ## Switching Between Modes | ||
|
|
||
| To switch from one mode to the other, enter: | ||
|
|
||
| ``` | ||
| fab config set mode <desired_mode> | ||
| ``` | ||
| There is no explicit mode switch command. The mode is determined by how you invoke the CLI: | ||
|
|
||
| where `<desired_mode>` is either `command_line` or `interactive`. Because the Fabric CLI needs to establish new authentication for each mode, you must re-authenticate after switching. The mode choice then remains in effect until you change it again. | ||
| - **Command-line mode** — run `fab <command>` with one or more arguments. | ||
| - **REPL mode** — run `fab` with no arguments. | ||
ayeshurun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,11 @@ def init_defaults(): | |
| current_config = read_config(config_file) | ||
| changed = False | ||
|
|
||
| # Migration: remove the deprecated 'mode' key (mode is now detected at runtime) | ||
| if fab_constant.FAB_MODE in current_config: | ||
| del current_config[fab_constant.FAB_MODE] | ||
| changed = True | ||
|
|
||
ayeshurun marked this conversation as resolved.
Show resolved
Hide resolved
ayeshurun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for key in fab_constant.FAB_CONFIG_KEYS_TO_VALID_VALUES: | ||
| old_key = f"fab_{key}" | ||
| if old_key in current_config: | ||
|
Comment on lines
56
to
66
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.