-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
: comprehensive support of TTY modes and capabilities
#254
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
This adds support for no-TTY, such as a CI environment, or via `ssh -T ...` to `choose`. However, this rewrites `read-key` to support such, and there needs further work as it still sends multiple characters in a single line under certain circumstances. However, `read-key` now does support no-TTY situations, such as pipes, or bash v3 character mashing. The complexity with this, is that there is no way native to just read one key at a time, and escape sequences can take multiple characters, as such the approach taken is to trim known escape sequences and then split the remaining. This is fine, however it means read-key now only supports known characters, and as such is more adequate to be considered a read-keyboard-key or so, as special escape sequences will require a lot of complexity to support, as they will need say our regex handling in `echo-wrap.awk` to be trimmed. This all means that `read-key` should be changed instead of reading one key at a time, now in an aggregate, it should just read everything and then shift the keys off.
- `read-key` and `confirm` have been rewritten
- `bash.bash`: add `__command_(missing|exists)`, `__try_sudo`, `__is_brew`, `__mkdirp`, `__sudo_mkdirp`, and `__can_read_decimal_timeout` - `(command-(exists|missing)|is-brew)`: use the `bash.bash` functions - `(command-(exists|missing|working)|is-brew)`: add tests - `debug-network:` fix bad maintenance over the years - `dorothy`: - move common helpers into `bash.bash`, and improve them - source the `bash.bash` that is appropriately local or remote - `(echo-(html|url)-coder|fs-dequarantine|get-desktop-theme|setup-util-(1password-cli|apple-(cli-tools|rosetta)|yt-dlp))`: fix functional incorrect function names - `expand-path-zsh` renamed to `expand-path.zsh` to follow modern conventions - `get-font`: improve performance - `is-tty`: remove unneeded `echo`s for modern conventions in tests - `setup-util`: conjoined a few redundant calls - `echo-mkdirp`: moved to beta commands as it is no longer used internally
…remote-name also remove update technique for legacy dorothy installations
balupton
force-pushed
the
dev/fix-253
branch
4 times, most recently
from
October 10, 2024 02:39
90f75d5
to
5b8aa12
Compare
rewrite `is-needle` to use this new `has_needles` helper and add tests
balupton
force-pushed
the
dev/fix-253
branch
8 times, most recently
from
October 11, 2024 07:06
3756222
to
1aecee3
Compare
balupton
force-pushed
the
dev/fix-253
branch
3 times, most recently
from
October 24, 2024 03:32
f0af795
to
555d324
Compare
…ing issue when testing get-terminal-position-support: fix crash when stdin not accessible get-terminal-tty-support: expand debug information to look for ways to ensure ask is only clearing input if it needed to is-interactive: simplify conditional logic read-key, is-shapeshifter: add (ctrl|alt)+(left|right) macos keys dorothy, dorothy-warnings: only output warnings by default if there are new warnings
balupton
force-pushed
the
dev/fix-253
branch
5 times, most recently
from
October 25, 2024 05:05
bf9d37a
to
ef37005
Compare
- add `debug-terminal-(stdin|tty)` - simplify `get-terminal-*-support` checks - `IFS=''` to `IFS=` as they are equivalent - get-terminal-theme: add `--ignore-cache` option - echo-file: correctly handle bat theme in cases where theme could not be detected, such as inside `ssh -T`
ask: - if non-reactive, use alternative screen buffer - add `--no-inline` option to force usage of alternative screen buffer if supported/reactive - this solves the impossibility of clearing the accurate amount of lines in no-TTY mode, as `ssh -T` and pipe/redirect/CI result in different line counts due to `ssh -T` outputting the enter key as a visual new line dorothy, setup-util-bash, setup-util-gh: use new `get-terminal-reactivity-support` command, and deprecate `is-interactive` add a `terminals-and-tty.md` document with the learnings and reasoning dorothy-warnings: prevent clearing of warnings causing warnings to be shown
/ref https://github.com/bevry/dorothy/actions/runs/11512899768 also fix `echo-regexp` including `stdinargs.bash` when it didn't need to
balupton
changed the title
WIP:
Oct 26, 2024
ask
, choose
, confirm
: better support no-TTY modeask
, choose
, confirm
: better support no-TTY mode
…revent edge case failures when the needle looks like an option
balupton
commented
Oct 26, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all good
balupton
changed the title
Oct 26, 2024
ask
, choose
, confirm
: better support no-TTY modeask
, choose
, confirm
: support no-TTY mode
balupton
changed the title
Oct 26, 2024
ask
, choose
, confirm
: support no-TTY modeask
, choose
, confirm
: appropriate support for various TTY modes and features
balupton
changed the title
Oct 26, 2024
ask
, choose
, confirm
: appropriate support for various TTY modes and featuresask
, choose
, confirm
: support for various TTY modes and features
balupton
changed the title
Oct 26, 2024
ask
, choose
, confirm
: support for various TTY modes and featuresask
, choose
, confirm
: better support for various TTY modes and capabilities
balupton
changed the title
Oct 26, 2024
ask
, choose
, confirm
: better support for various TTY modes and capabilitiesask
, choose
, confirm
: comprehensive support for TTY modes and capabilities
balupton
changed the title
Oct 26, 2024
ask
, choose
, confirm
: comprehensive support for TTY modes and capabilitiesask
, choose
, confirm
: comprehensive support of TTY modes and capabilities
This was referenced Oct 28, 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.
/close #253 #234
general:
IFS=''
toIFS=
as they are equivalentdorothy-warnings
andcommands.deprecated
suggestionsecho
to either__print_line
or__print_lines
echo-style
calls into a single call for performancedocs:
terminals-and-tty.md
:is-tty --test
moved into newdebug-terminal-(tty|stdin)
and learnings documented in this doc fileprompts.md
:readme
:ci:
dorothy-workflow.yml
:shellcheckrc
:SC2016
, it is always intentionalSC2059
, it is always intentionaldeprecate
tty.bash
,choose-menu
,choose-option
,echo-clear-line
,echo-color-enabled
,echo-element
,echo-quiet-enabled
,echo-title
,is-color-enabled
,is-interactive
,is-match
,is-quiet-enabled
,is-tty
is-tty --test
debug information moved intodebug-terminal-(stdin|tty)
beta commands, and add more informationget-terminal-alternative-support
get-terminal-color-support
:ssh -T ...
, which does support colorsget-terminal-cursor-line-and-column
get-terminal-device-file
get-terminal-lines-and-columns
get-terminal-position-support
get-terminal-quiet-support
:get-terminal-color-support
convention, however keep same functionality, this could be a mistake - will need to evaluateget-terminal-reactivity-support
get-terminal-size-support
get-terminal-title-support
:get-terminal-tty-support
move
echo-exit-affirmative
,echo-mkdir
,echo-nothing-or-fail
to beta commands as they are no longer (or were never) used internallystdinargs.bash
:[[ ... ]]
instead oftest
/[
to better handle edge cases, such as a trailing line containing only>
bash.bash
:__print_line ...
, use__print_lines ...
instead--
argument in appropriate functions[[ ... ]]
instead oftest
/[
to better handle edge cases__substr
shim, fix forcpr
andecho-style
mapfile
shim for bash v3__is_brew
,__command_(missing|exists)
,__try_sudo
,__is_brew
,__mkdirp
,__sudo_mkdirp
,__escape_shapeshifting
,__is_shapeshifter
,__can_read_decimal_timeout
has_needles
however it wasn't justified compared to continuingis-needle
zsh.zsh
:bash.bash
changesstyles.bash
andecho-style
:styles.bash
:newline
\e[J
instead of\e[2J
for reasoning documented inside the filecode_notice
style and replace tocode-notice1
ask
,choose
, andconfirm
to be consistent and to support no-TTY modeecho-style
:--=...
,--=
,--
argumentsecho-style --tty
instead ofecho-style >/dev/tty
as the former can support when/dev/tty
doesn't existask
,choose
,confirm
,read-key
,is-shapeshifter
,echo-count-lines
,echo-clear-lines
,echo-revolving-door
,echo-wrap
,eval-helper
:ask
:--no-inline
option to force usage of alternative screen buffer if supported/reactivessh -T
and pipe/redirect/CI result in different line counts due tossh -T
outputting the enter key as a visual new linechoose
:git-helper
use caseconfirm
:--required
not always enforcing requirementeval-helper
:echo-clear-lines
:--piped
option has been removed, a new--here-string
argument has been addedecho-wrap
to ensure correct behaviour--column=*
alias for--width=*
, and supports--count=*
option if we already know how many lines we want to clearecho-count-lines
:echo-revolving-door
:echo-wrap
:is-shapeshifter
:bash.bash
helpersread-key
:(ctrl|alt|shift)+(left|right)
macos keys, addctrl+a
(all key)brew
:brew-installed
:--quiet
argument46
if brew is not installed(command-(exists|missing|working)|is-(brew|needle))
:command-working
:3
instead of1
debug-network:
dorothy
:coreutils
on alpine, removeps
dependencyremote_name
automationbash.bash
, and improved thembash.bash
that is appropriately local or remoteslug
/branch
/reference
/remote-name
, properly enabling support for branches, PRs, and forksgit-helper
which are now resolvedgit-helper
existed, and it has existed for a long time now, multiple years__eval_wrap
helper for debug clarityask
,dorothy
,setup-util-bash
,setup-util-gh
get-terminal-reactivity-support
command instead of the deprecatedis-interactive
dorothy
,dorothy-warnings
,init.*
:dorothy-warnings
for deprecations and other warningsdorothy
,fs-realpath
,symlink-helper
:busybox
orcoreutils
and react accordinglyreadlink
on alpine'sbusybox
doesn't support needed optionsrealpath
on alpine'sbusybox
doesn't support any optionsbusybox
implementation to fallbacksymlink-helper
:echo-regexp
,echo-regexp.ts
:stdinargs.bash
when it didn't need to[[:XXX:]]
and[:XXX:]
formsecho-file
andget-terminal-theme
:get-terminal-theme --ignore-cache
optionbat
theme in cases where theme could not be detected, such as insidessh -T
bat
andplain
outputecho-quote
,echo-escape-command
,echo-escape-bash
,echo-lines
,config-helper
,dorothy-config
,fs-size
,mount-helper
,nvm-env
,setup-dns
,sudo-helper
,video-merge
, and so on:echo-lines
andconfig-helper
:--quote=
option now supports the type of quote format you wantconfig-helper
this will default to autodetection based on the filetype we are writing toecho-quote
:--single
and--double
arguments(echo-(html|url)-coder|fs-dequarantine|get-desktop-theme|setup-util-(1password-cli|apple-(cli-tools|rosetta)|yt-dlp))
:echo-escape-special
:echo-mkdir
:echo-nothing-or-fail
:echo-substr
new command:__substr
helper inbash.bash
echo-wait
:expand-path-zsh
renamed toexpand-path.zsh
:fs-rm
:get-font
:get-installer
:setup-util-ps
git-helper
:verify
action and steppath
not sent toreview
actionis-abort
:ignore-empty
option, and hardcode how it is handledis-nonempty-file
:setup-util
:bash.bash
helpersecho-style
callsbash
, output a warning/dev/tty
if supported and appropriatesetup-util-bash
:echo-style
calls for performance, includesetup-util --check
for performancesetup-environment-commands
:rubygems
bash.bash
helperscommands.deprecated
setup-mac-brew
:git-helper verify
actionsetup-util-node
:git-helper verify
actionadd
setup-util-ps
until-success
:--delay=...
alias for--interval=...
waiter
:--magic
optionwhat-is-running
:ps
andprocs
, and install the appropriate fallback if both are missingvideo-merge
:is-headful
which is appropriate, instead of the deprecatedis-tty
oz
:new beta commands:
echo-revolving-screen
command that unfortunately doesn't work properly and I don't know whymerged commits:
https://github.com/bevry/dorothy/actions/runs/11323459946/job/31486170602#step:4:11