Skip to content
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
merged 51 commits into from
Oct 27, 2024

Commits on Oct 1, 2024

  1. choose, echo-wrap, read-key: support no-TTY

    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.
    balupton committed Oct 1, 2024
    Configuration menu
    Copy the full SHA
    7f91040 View commit details
    Browse the repository at this point in the history

Commits on Oct 5, 2024

  1. WIP: choose, confirm, read-key: improve no-TTY support

    - `read-key` and `confirm` have been rewritten
    balupton committed Oct 5, 2024
    Configuration menu
    Copy the full SHA
    2c1b508 View commit details
    Browse the repository at this point in the history

Commits on Oct 9, 2024

  1. bash.bash: add common helpers for performance

    - `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
    balupton committed Oct 9, 2024
    Configuration menu
    Copy the full SHA
    c7f31b1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ba73e79 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2582cdf View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    1dbdd43 View commit details
    Browse the repository at this point in the history

Commits on Oct 10, 2024

  1. Configuration menu
    Copy the full SHA
    2fc7757 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    47f29cb View commit details
    Browse the repository at this point in the history
  3. dorothy: rejig clone and update to all support slug/branch/reference/…

    …remote-name
    
    also remove update technique for legacy dorothy installations
    balupton committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    b60ef24 View commit details
    Browse the repository at this point in the history
  4. fix mistakes in WIP commits

    /ref c7f31b1 - `option_commands` leftover in `bash.bash` helpers
    /ref b60ef24 - use new `is_remote` var that is accurate
    balupton committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    ee11038 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7b9d99c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    c48e182 View commit details
    Browse the repository at this point in the history
  7. confirm, read-key: linting

    balupton committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    4098286 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    7a3236c View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    4193b8e View commit details
    Browse the repository at this point in the history
  10. bash.bash: add has_needles helper for performance

    rewrite `is-needle` to use this new `has_needles` helper and add tests
    balupton committed Oct 10, 2024
    Configuration menu
    Copy the full SHA
    64c9cf6 View commit details
    Browse the repository at this point in the history

Commits on Oct 11, 2024

  1. Configuration menu
    Copy the full SHA
    6b7f98a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e15cab8 View commit details
    Browse the repository at this point in the history
  3. bash.bash: linting

    /ref 64c9cf6
    balupton committed Oct 11, 2024
    Configuration menu
    Copy the full SHA
    8a4583b View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c71c557 View commit details
    Browse the repository at this point in the history

Commits on Oct 15, 2024

  1. WIP: removed tty.bash for get-terminal-* commands

    todos:
    - `ask` no-tty support
    - documentation of fixes, new features, changes, deprecations
    balupton committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    5def66e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    acee8c9 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    06a2cae View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    369ff92 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    99ac325 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    a9a57f5 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    41de4c2 View commit details
    Browse the repository at this point in the history
  8. echo-file: fix bat usage, all: improve styling

    styles.bash: add some escaped styles, such as `newline`
    
    echo-style: support '--=...', '--=', '--' arguments
    
    change `echo` to `__print_lines`
    
    compress multiple `echo-style` calls into one
    
    fix broken `code_notice` style and replace to `code-notice1`
    
    implement new styles where appropriate, however this is not comprehensive at all
    
    use `echo-style --tty` instead of `echo-style >/dev/tty` as the former can support when `/dev/tty` doesn't exist
    balupton committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    fc24131 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    f62bebd View commit details
    Browse the repository at this point in the history
  10. choose and read-key bugfixes

    choose:
    - don't crash on unknown keys, instead flash bell
    - improve performance of legend rendering
    - don't hide/show cursor on environments that don't support it
    
    read-key:
    - don't output unknown keys by default
    - support `shift+(left|right)` on macos
    - fix tests for `is-tty` deprecation
    
    get-terminal-color-support:
    - if ci that isn't github, continue to fail, however if dumb terminal and not ci, continue to fallback
        - this enables fallback on `ssh -T ...`, which does support colors
    
    get-terminal-quiet-support:
    - adapt for the `get-terminal-color-support` convention, however keep same functionality, this could be a mistake - will need to evaluate
    
    get-terminal-title-support:
    - vscode doesn't support titles, so fail on vscode
    
    video-merge:
    - use `is-headful` which is appropriate, instead of the deprecated `is-tty`
    
    styles.bash:
    - use support vars at the begining for clarity and performance
    
    oz:
    - cleanup a little bit, now that docs are elsewhere
    
    todos:
    - check if `--quiet=''` causes crashes
    balupton committed Oct 15, 2024
    Configuration menu
    Copy the full SHA
    5405c39 View commit details
    Browse the repository at this point in the history

Commits on Oct 16, 2024

  1. Configuration menu
    Copy the full SHA
    b4ef3c8 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    383e36a View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    648843c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    598918e View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    cc483c3 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    888b090 View commit details
    Browse the repository at this point in the history

Commits on Oct 23, 2024

  1. add dorothy-warnings, a deprecation system

    re-add some WIP deleted commands to `commands.deprecated` and move some longstanding deprecated commands into it, also remove duplicate `is-match` from 7ee7f6c
    
    deprecate `echo-clear-line`
    
    until-success: things that should be output to the terminal device file are now outputted there
    
    move ansi escape code documentation from various commands into a new `ansi-escape-codes.md` documentation file
    
    update the outdated `prompts.md` documentation file
    balupton committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    d99a9a6 View commit details
    Browse the repository at this point in the history
  2. consistentcy for commands.deprecated

    second part of 4ee1fa4 to maintain renames
    balupton committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    a37639d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a3ba02f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    e8a0640 View commit details
    Browse the repository at this point in the history
  5. echo-clear-lines: prep for improvements

    also revert broken WIP echo-clear-lines argument usage, with correct `< <(...)` usage
    balupton committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    713322d View commit details
    Browse the repository at this point in the history
  6. improvements to clearing, and resolve setup-util(-bash) edge case

    - brew-installed: support --quiet argument, return exit status 46 if brew is not installed
    - echo-quote: support --double and --single arguments
    - echo-revolving-door: remove some outdated implementation comments
    - fs-rm: note when trash is not available
    - setup-util:
        - output to /dev/tty if supported and appropriate
        - if uninstalling/upgrading the currently executing bash, output a warning
        - redo the clearing functionality to implement modern conventions and support a wide range of edge cases, such as when installer outputs more than LINES, or when clear is not available, or when the installer needs interaction
        - don't remove non-xdg-bins when upgrading as that causes issues with homebrew if the homebrew-intalled bin was removed but homebrew still thinks it is installed
    - setup-util-bash: detections and workarounds if trying to uninstall/upgrade the currently executing bash
    - add an `echo-revolving-screen` command that unfortunately doesn't work properly and I don't know why
    - styles.bash: change clear screen to use `\e[J` instead of `\e[2J` for reasoning documented inside the file
    balupton committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    8324b75 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    52958a2 View commit details
    Browse the repository at this point in the history
  8. ask/choose/confirm: complete no-TTY support

    /close #253
    
    - shellcheckrc: add `SC2059`, and add docs on all the disabled rules
    - ask: rewrote for modern conventions, support no-TTY, fix read failures not being output
    - ask/choose/confirm: consistent commentary styling
    - choose: fix blockquote line being a different color or breaking colors
    - confirm: fix and improve the WIP no-TTY support, now complete
    - dorothy: prompt for lint upgrade before dev deps, to speed up UX
    - echo-clear-lines: rewrote to support all known edge cases
    - echo-count-lines: add note that it doesn't wrap
    - echo-escape-command: use new `__quote` helped in `bash.bash` to support ANSI Escape Codes
    - echo-quote: add tests, add support for `--single` and `--double` arguments
    - echo-regexp(.ts)?: better support for character classes, supporting `[[:XXX:]]` and `[:XXX:]` forms
    - echo-revolving-door: rewrote to support all known edge cases
    - added `echo-substr`: as command alias for `__substr` helper in `bash.bash`
    - echo-wrap: fix help errors not showing, support --column=* alias for --width=*
    - eval-helper: updated for TTY changes, aand fix all known edge cases
    - expand-path.zsh: same functionality, but rewrote for clarity
    - setup-util: linting, and only output the output if there is output
    - setup-util-bash: compact `echo-style` calls for performance, include `setup-util --check` for performance
    - until-success: rewrote for new TTY conventions
    - echo-escape-special: fix everything being dumped together
    - is-shapeshifter: rewrote and add tests, to fix all known edge cases, and now uses `bash.bash` helpers
    - bash.bash:
        - remove deprecated usage of `__print_line ...` use `__print_lines ...` instead
        - support initial `--` argument in appropriate functions
        - rewrite to use [[ ... ]] instead of test/[ to better handle edge cases
    - stdinargs.bash:
        - rewrite to use [[ ... ]] instead of test/[ to better handle edge cases, such as a trailing line containing only `>`
    - zsh.zsh:
        - consistency with `bash.bash` changes
        - rewrote and fixed `__substr` helper for edge cases
        - added `is_shapeshifter` and `__escape_shapeshifting` helpers, used in `is-shapeshifter`
    - ansi-escape-codes.md: removed excess docs
    
    todos:
    
    - decide if ask/choose/confirm linger should be outputted to stderr if there is commentary and a sucess code but no linger, check if consistent with choose
    - setup-util: consider new wrapper for the font selection too
    balupton committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    099bb6b View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2024

  1. ask/choose/confirm: fix broken tests, although ask test has a clear…

    …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 committed Oct 24, 2024
    Configuration menu
    Copy the full SHA
    0dfebda View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2024

  1. improvements to TTY and STDIN reporting

    - 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`
    balupton committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    613cec8 View commit details
    Browse the repository at this point in the history
  2. ask: rewrote for new stdin/tty learnings, properly support no-TTY

    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
    balupton committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    d605711 View commit details
    Browse the repository at this point in the history
  3. use the correct quote/escape for the context

    /ref https://github.com/bevry/dorothy/actions/runs/11512899768
    
    also fix `echo-regexp` including `stdinargs.bash` when it didn't need to
    balupton committed Oct 25, 2024
    Configuration menu
    Copy the full SHA
    d2b29cb View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    36e8c75 View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2024

  1. Configuration menu
    Copy the full SHA
    1c7b588 View commit details
    Browse the repository at this point in the history
  2. re-add --needle= prefix on needle option on is-needle calls, to p…

    …revent edge case failures when the needle looks like an option
    balupton committed Oct 26, 2024
    Configuration menu
    Copy the full SHA
    4f66b71 View commit details
    Browse the repository at this point in the history