-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
ask, choose, confirm: implement #99, #213, #188 #229
Merged
Merged
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
Still need to imlpement: - `--linger` - `--confirm-default=no` - `--confirm-input` ...and to make them consistent between ask, confirm, choose. This removes `--filter` from choose, as it is better facilitated by the new `--default(s)-fuzzy=` /close #188
changes: - bash.bash: - native __ prefix on methods, b/c alias (rather than non-performant inverse) - removed unused __print_lines_no_trail - ask, choose, confirm: - fix question title and body implementation, title is uniformly bold - linger answer will be dim - fix outdated linger option implementation - implement confirm on choose - implement linger on confirm - new options implemented in caller where appropriate - dorothy: remove require_globstar as already provided by bash.bash - get-flag-value: - remove unused complex --*-fallback options, fix inversions - update tests - macos-settings: remove fodder usage, was unnecessary todos: - need to update tests for ask, confirm, choose
…ults, which unfortunately was left behind on my mac mini when I did the rebase on my macbook # Conflicts: # commands/ask # commands/choose-menu # commands/confirm # commands/setup-git # commands/sparse-vault Also: - implement better timeout and error handling, no need for a delay anymore, and now commentary visible in linger - update callers accordingly, also update `dorothy` to remove unnecessary indentation, update `echo-lines` to remove typo in comment - add tests for the `echo-trim-colors` new handling of inline Still need to: - `choose`: - update tests for rewrite - fix duplicate `DEFAULTS` in choose (probably a long-standing regression) - support multiple default matches in `--no-multi` (as done by `echo-checksum`) by adding the concept of preferences - see details at #188 (comment) - add linger and timeout tests to `ask`, `choose`, `confirm`
- ask/choose/confirm: remove delay on errors - choose-path: fix help usage convention - read-key: rewrote hotkey handling for documented cross-os support, with support for more hotkeys - styles: documented terminal emulator support for all complex styles - choose: rewrite for page-up, page-down, home, end support, and do infrastructure for new confirm menu and paging indicators
this adds the infrastructure for a possible "cancel" menu mode
/close #231 Co-authored-by: Benjamin Lupton <[email protected]>
changes: - deprecated `echo-element` and `echo-segment`, as they are now supported by `echo-style` - `echo-style` and `styles.bash` updated for begin/end and color/nocolor styles - `echo-style` updated to do the minimal writes for performance and simplicity - `styles.bash` now has the `choose` styles, so `choose` theme can be customised by the user - `choose` fixed and styled no selection / no items /close #232 /ref #231 #188
- choose: - will now resize terminal if terminal too small, and if resize failed, output a error mode until resolved - fix terminal title showing false count for selected after refactor - fix middle and bottom bars being incorrect after refactor - fixed commas appearing in legend - fixed odd behaviour with cursor behaviour - fixed bad selected rendering - read-key: improve documentation, note keyboards, note symbol divergence, fix macos paging hotkeys - styles.bash: fix unbound var /ref #188
now that they are deprecated as their functionality has been added to echo-style /ref #188
- choose: `is_preference` -> `__is_preference` - dorothy: fix false unsafe flagging on for conditionals /ref https://github.com/bevry/dorothy/actions/runs/10124332719/job/27998559165 /ref #188
echo-style, styles.bash: added new helpers for caching color/nocolor lookups refactors also fix respect of no-color /ref #188
choose: - add more tests - fix conditional actions causes crashes when conditions not met echo-style, styles: - fix fetching end styles
choose, styles.bash: - renamed default to defaults choose: - do revert before confirm cancel - introduce fallbacks array for containing a single default for single mode - rename last_index to last to avoid confusion
ask: - fix non TTY causing failure - fix repeat prompts concat instead of reset bash.bash: - fix outdated bash version ask, choose: - linting /ref https://github.com/bevry/dorothy/actions/runs/10284567335/job/28460877061
fetch: fix curl still causing pipe errors setup-util-1password, setup-util-1password-cli: update for brew changes
config-helper just seems flakey in general, so reduce its timeout and run it three times choose failures were actually read-key failures, so reduce the timeout dorothy move unsafe calls to linting, and use arrays with flakey array /ref d513c42 /ref https://github.com/bevry/dorothy/actions/runs/10289349834/job/28476911341
dorothy: add echo-wait to flakey choose, config-helper: use 3 second delay on ci /ref https://github.com/bevry/dorothy/actions/runs/10291311574/job/28483286557
pipx now uses .local, and it seems if the old `Library/Application Support/pipx` location exists, everything falls apart, so remove the old location as well as the new preferred one (as usual) before reinstalling solves these errors: ``` < 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'katcr' >⚠️ Found a space in the home path. We heavily discourage this, due to multiple incompatibilities. Please check our docs for more information on this, as well as some pointers on how to migrate to a different home path. creating virtual environment...⚠️ Not removing existing venv /Users/balupton/Library/Application Support/pipx/venvs/katcr because it was not created in this session Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module> sys.exit(cli()) ^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli return run_pipx_command(parsed_pipx_args, subparsers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command return commands.install( ^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install venv.create_venv(venv_args, pip_args, override_shared) File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages output = run_subprocess( ^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess completed_process = subprocess.run( ^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/katcr/bin/python' Installing to existing venv 'katcr' </ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'katcr' >[1] < 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'poetry' >⚠️ Found a space in the home path. We heavily discourage this, due to multiple incompatibilities. Please check our docs for more information on this, as well as some pointers on how to migrate to a different home path. creating virtual environment...⚠️ Not removing existing venv /Users/balupton/Library/Application Support/pipx/venvs/poetry because it was not created in this session Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module> sys.exit(cli()) ^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli return run_pipx_command(parsed_pipx_args, subparsers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command return commands.install( ^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install venv.create_venv(venv_args, pip_args, override_shared) File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages output = run_subprocess( ^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess completed_process = subprocess.run( ^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/poetry/bin/python' Installing to existing venv 'poetry' </ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'poetry' >[1] < 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'stig' >⚠️ Found a space in the home path. We heavily discourage this, due to multiple incompatibilities. Please check our docs for more information on this, as well as some pointers on how to migrate to a different home path. creating virtual environment...⚠️ Not removing existing venv /Users/balupton/Library/Application Support/pipx/venvs/stig because it was not created in this session Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module> sys.exit(cli()) ^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli return run_pipx_command(parsed_pipx_args, subparsers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command return commands.install( ^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install venv.create_venv(venv_args, pip_args, override_shared) File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages output = run_subprocess( ^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess completed_process = subprocess.run( ^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/stig/bin/python' Installing to existing venv 'stig' </ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'stig' >[1] < 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'youtube_dl' >⚠️ Found a space in the home path. We heavily discourage this, due to multiple incompatibilities. Please check our docs for more information on this, as well as some pointers on how to migrate to a different home path. creating virtual environment...⚠️ Not removing existing venv /Users/balupton/Library/Application Support/pipx/venvs/youtube-dl because it was not created in this session Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/__main__.py", line 14, in <module> sys.exit(cli()) ^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 1149, in cli return run_pipx_command(parsed_pipx_args, subparsers) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/main.py", line 267, in run_pipx_command return commands.install( ^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/commands/install.py", line 92, in install venv.create_venv(venv_args, pip_args, override_shared) File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/venv.py", line 172, in create_venv pipx_pth = get_site_packages(self.python_path) / PIPX_SHARED_PTH ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 132, in get_site_packages output = run_subprocess( ^^^^^^^^^^^^^^^ File "/Users/balupton/Library/Python/3.12/lib/python/site-packages/pipx/util.py", line 183, in run_subprocess completed_process = subprocess.run( ^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/Cellar/[email protected]/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/subprocess.py", line 1955, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: '/Users/balupton/Library/Application Support/pipx/venvs/youtube-dl/bin/python' Installing to existing venv 'youtube-dl' </ 'python3' '-m' 'pipx' 'install' '--include-deps' '--force' 'youtube_dl' >[1] ```
balupton
added a commit
that referenced
this pull request
Aug 10, 2024
`ask` and `choose` now use our own `echo-wrap` and `echo-count-lines` instead of `gfold`, `gfmt`, `gwc`. The reasoning for this was that they did not handle ansi escape codes, including colours, nor indentation of broken lines correctly. To achieve this, I have introduce `echo-gnu-command` to fetch a GNU command (or fallback), with optional install. Calls to `echo-gnu-command` may need `--no-fallback` if it turns out they actually require the GNU variant. Considering this, we may be able to remove the symlink alias inside `setup-util-gawk` and `setup-util-gsed`. This also fixes an issue with `choose` where the right arrow (page down) was not working when on the last item of a page. Finally, this improves the formatting of subsequent lines in choose, they now have a continious quote line. I have also figreud out when the CI is showing truncated output for choose, it occurs with `paging_supported='no'` this will be resolved another day.
balupton
added a commit
that referenced
this pull request
Aug 10, 2024
`ask` and `choose` now use our own `echo-wrap` and `echo-count-lines` instead of `gfold`, `gfmt`, `gwc`. The reasoning for this was that they did not handle ansi escape codes, including colours, nor indentation of broken lines correctly. To achieve this, I have introduce `echo-gnu-command` to fetch a GNU command (or fallback), with optional install. Calls to `echo-gnu-command` may need `--no-fallback` if it turns out they actually require the GNU variant. Considering this, we may be able to remove the symlink alias inside `setup-util-gawk` and `setup-util-gsed`. This also fixes an issue with `choose` where the right arrow (page down) was not working when on the last item of a page. Finally, this improves the formatting of subsequent lines in choose, they now have a continious quote line. I have also figreud out when the CI is showing truncated output for choose, it occurs with `paging_supported='no'` this will be resolved another day.
balupton
added a commit
that referenced
this pull request
Aug 10, 2024
`ask` and `choose` now use our own `echo-wrap` and `echo-count-lines` instead of `gfold`, `gfmt`, `gwc`. The reasoning for this was that they did not handle ansi escape codes, including colours, nor indentation of broken lines correctly. To achieve this, I have introduce `echo-gnu-command` to fetch a GNU command (or fallback), with optional install. Calls to `echo-gnu-command` may need `--no-fallback` if it turns out they actually require the GNU variant. Considering this, we may be able to remove the symlink alias inside `setup-util-gawk` and `setup-util-gsed`. This also fixes an issue with `choose` where the right arrow (page down) was not working when on the last item of a page. Finally, this improves the formatting of subsequent lines in choose, they now have a continious quote line. I have also figreud out when the CI is showing truncated output for choose, it occurs with `paging_supported='no'` this will be resolved another day.
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.
Implements #99, #213, #188
renames:
bash.bash
helpers now have__
prefix to indicate they are safe for conditional usagerequire_array
is now__require_array
require_globstar
is now__require_globstar
print_string
is now__print_string
print_line
is now__print_line
print_lines
is now__print_lines
lowercase_string
is now__lowercase_string
uppercase_first_letter
is now__uppercase_first_letter
choose-option
is nowchoose
choose-option --filter=
is nowchoose --default-fuzzy=
choose-menu
is nowchoose --index
echo-element --open= --close= --openclose=
is nowecho-style --element= --/element= --element/=
echo-segment
functionality is now inlined intoecho-style
, to avoid conflict, prior echo-style functionality changed to:echo-style --h1= --h2= --h3=
is nowecho-style --header1= --header2= --header3=
echo-style --g1= --g2= --h3=
is nowecho-style --good1= --good2= --good3=
echo-style --e1= --e2= --e3=
is nowecho-style --error1= --error2= --error3=
echo-style --n1= --n2= --n3=
is nowecho-style --notice1= --notice2= --notice3=
new functionality:
echo-style
now inlinedecho-element
andecho-segment
functionality, complex heading and element renderings are now possilbechoose
,ask
,confirm
now all support--linger
for retaining the question and answer in the TTY afterwards, and consistent question and question detail argument handlingask
now supports editing a default valuechoose
interface has been rewritten for clarity and performance, with improved and comprehensive interaction and paging supportchoose
no longer supports filters, but instead--default-fuzzy
which has clearer usage, which is especially useful when say selecting a matching encryption/hashing algorithmread-key
now supports way more special keyschoose
andask
now have a--skip-default=
aka--no-confirm-default=
optionchanged functionality:
choose
,ask
,confirm
now have consistent confirm and linger usagechoose
will default to defaults on timeout, rather than a modified but not confirmed selectionchoose
,ask
,confirm
now have clearer and speedier timeout handling, as well as consistent timeout styling that respects color/nocolor modeecho-style
andstyles.bash
has been rewritten to clearly support color, nocolor, and end styles, as well as performance has improved by only doing a single write rather than streaming writes, and missing styles will not be output with--debug
modeecho-trim-colors
better support for inline stringsget-flag-value
removed affirmative options and simplified with only boolean and invert options, added more teststrivial changes:
choose-path
fix help argumentsdorothy
fix false flag unsafe name checksplaces to see the most improvements:
echo-checksum --algorithm=sha
setup-util-nerd-fonts
setup-utils --configure
sparse-vault
ssh-helper