-
Notifications
You must be signed in to change notification settings - Fork 0
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
Improve user experience of interactive mode #136
Open
luator
wants to merge
8
commits into
fkloss/numpy2
Choose a base branch
from
fkloss/tab-complete
base: fkloss/numpy2
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use the readline module to add tab-completion for the available commands. This also automagically gives us arrow-up-history for the input prompt. Note that the history is not perfect as it also includes input from other prompts (e.g. the question whether an existing output directory should be deleted) but I think it's good enough. Resolves #47.
Use the cmd.Cmd class for interactive mode. This gives some benefits over doing things manually: - No need to take care of tab-completion ourselves - `help` command for free - Code gets a bit nicer - Allows to easily add command arguments (not done in this commit, though)
Instead of just always exiting the command loop after one command, make it based on the return value of the command function. If all goes well, it should return True to exit the loop but in case of an error (e.g. invalid ID provided), it can return False, so the prompt stays open and the user can try again. It is always possible to exit the loop by simply pressing enter on an empty line.
Instead of prompting for it after entering the command, it now expected the job ID as argument (e.g. `show_job 42`). There is also tab-completion for the argument (not sure how useful this is but it might be nice to easily get a list of valid IDs).
This results in more nicely structured output, which is easier to read.
I don't see any gain in being told that the following is the "list of running jobs" after I just entered `list_running_jobs` (which will still be visible in the terminal just one line above). Simple remove those prints from the various list functions.
luator
changed the title
Tab-completion & history for interactive mode
Improve user experience of interactive mode
Nov 7, 2024
This was
linked to
issues
Nov 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Use
cmd.Cmd
for interactive mode. This gives some benefits over doing things manually:help
command for freeshow_job
which now expects the ID as argument instead of separately prompting for it (as a bonus, there is even tab completion for the argument :) ).While working on this, also make the output a bit nicer:
list_successful_jobs
).Cmd.columnize
for lists of job IDs. Results in much nicer, more readable output.Note that calling
show_job
without argument now results in an error (expects ID as argument). I don't consider this as breaking change w.r.t. versioning, though, as it only affects the interactive command, i.e. no existing script/config or the like should break due to this change.Resolves #47.
Resolves #135.
Do not merge before