Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Piotr Murach
    @piotrmurach
    Hi @TayKangSheng You're right it makes little sense to have a default option that isn't used. I'd open an issue on GitHub, or even better if you have a minute to cook up a fix and submit PR that would be really great.
    Tay Kang Sheng
    @TayKangSheng
    sure thing! thanks for the clarifacton :)
    JohnConfidence
    @JohnConfidence
    Hey! Does tty-prompt or tty-table play well with Curses? I ask because I couldn't find a way to refresh the screen if the content of a table or prompt changes. Would I be able to run tty-prompt or tty-table within a curses window and call Curses.refresh to get content to update?
    Piotr Murach
    @piotrmurach
    @JohnConfidence TTY components don't use curses so that they can work on all platforms. Can you mix the two? I think you can but you will have to test yourself. If you wish to refresh the terminal window, you can use ANSI codes, for example, tty-cursor has clear_screen code. I hope this helps.
    Robert Fletcher
    @mockdeep
    Hey there, I'm trying to combine tty-progressbar with tty-prompt.
    Any advice on how to make them play nice together?
    Essentially, I want to show a progressbar above a prompt asking the user for input.
    Or below, doesn't really matter.
    Robert Fletcher
    @mockdeep
    nm, think I figured it out.
    Adding a \n to the format string seems to have done the trick.
    TTY::ProgressBar.new("progress [:bar]\n")
    Side note, render seems like it might be good to have as public api.
    Danny Ben Shitrit
    @DannyBen

    Hey everybody. I wonder if someone has any tip on how to do this: I would like to have TTY::Prompt return a value from a keypress event. Something like this:

    prompt = TTY::Prompt.new
    prompt.on :keypress do |event|
      if event.key.name == :page_up
        prompt.return 'four' # <= I want something like this
      end
    end
    
    response = prompt.select "Select", %w[one two three]
    puts "response: #{response}"

    I have spent the last two hours digging in the Prompt and Reader code trying to figure it out, until I admitted defeat and realized Piotr's code is way above my paygrade....

    Kévin Le Bon
    @Docteur-Lalla

    Hi everyone. I am working on a shell and I have trouble with TUI applications such as man, less, vim... I am using TTY::Command to run these commands in a PTY but it seems the input, the output, probably both are not wired correctly. Even the following code does not display things correctly (let alone input).

    runner = TTY::Command.new pty: true, output: some_logger
    runner.run 'vim'

    Are these applications supposed to be supported (am not sure if it's ncurses specific or related to termcaps)? If not, is it planned? Am I doing it wrong?

    Thank you in advance :)

    Piotr Murach
    @piotrmurach
    @Docteur-Lalla Running editor command in a child process is problematic for many reasons, including the fact that the process never finishes. Try running Ruby's %x[vim] as a test. As an alternative, you can try tty-editor .
    Piotr Murach
    @piotrmurach
    @DannyBen Unfortunately there is no such way to do this. The global prompt doesn't have access to the current run select menu.
    Kévin Le Bon
    @Docteur-Lalla
    @piotrmurach Thank for the quick response. Well `%x/vim/ provides the same results as I expected. tty-editor does not really correspond to my use case but the code is insightful, I'll try to find a solution from here. Thanks!
    Ben
    @benjamin-hull
    Hello CLI friends! Got a quick question regarding multi_select - does it, or should it, accept a required option to force the user to select at least one value?
    I guess a min option to go with max could also work: min: 1 would ensure at least one option is selected - I can see that doesn't exist yet, though I'm not certain on the required side
    Mads Ohm Larsen
    @omegahm
    @piotrmurach Hi Piotr. I first want to say thanks for a great project! I just love the ease that tty-* gives me to make nice CLI.
    When using teletype to create a project, it creates a templates folder within lib/PROJECT. What is this meant for?
    Pranav Goswami
    @prango
    @piotrmurach Hi Piotr ! Amazing gem :) Just wanted to ask is there way to pipe TTY::Prompt output to LOG ? Right now the way i am doing in building warper around to and Logging args and answers.
    🐔🍷 The Journal of Unciteable Scholarship
    @anbayanyay_twitter
    Hi @piotrmurach , thanks for the great code! I am having an issue, though, with tty::reader through a gserver socket.
    🐔🍷 The Journal of Unciteable Scholarship
    @anbayanyay_twitter
    Hi @piotrmurach , thanks for the great code! I am having an issue, though, with tty::reader through a gserver socket. I start the reader with: rio = TTY::Reader.new(input: sio, output: sio) and I read lines with readline = rio.read_line("\r#{serverIdentifier}:>") ... What happens is when a user telnets to the server, each time they type a character, the prompt and their input is tabbed 8 spaces right. I love the previous command retrieval, and if I could get this glitch straightened out, I would be ecstatic! Do you have suggestions for me to try? Many thanks.
    🐔🍷 The Journal of Unciteable Scholarship
    @anbayanyay_twitter
    I solved this tab issue by adding the raw option to the read_line call. Happy as a clam! Thanks again.
    b1tt
    @b1tt0
    hi! im having troubles with tty-cursor running on zsh. it seems to do nothing
    Piotr Murach
    @piotrmurach
    @prango The initializer accepts :output option which accepts stream like objects. However, I must warn you that the output from TTY::Prompt would be extremely verbose including many terminal control characters. Not sure this is what you need.
    @anbayanyay_twitter This issue is not specific to TTY::Reader. This is to do with cooked vs raw terminal mode. Even if you use Ruby's getc method you will get similar behaviour. Had a similar issue recently to do with TTY::Prompt behaviour (see piotrmurach/tty-prompt#137). Glad you managed to figure this out!
    @b1tt0 I can assure you that TTY::Cursor works fine. Please make sure that you print cursor content to the terminal (read https://github.com/piotrmurach/tty-cursor#1-usage)
    Adam Fleishaker
    @afleishaker
    Heya all, is it still the case that tty-prompt and tty-box are incompatible together out of the box without major overhaul?
    Adam Fleishaker
    @afleishaker
    And a followup, is progressbar able to returned without printing?
    Daniel Vartanov
    @DanielVartanov
    @afleishaker I've used them both in my last project, they work fine. I wonder what was the problem in the past? I don't see a reason of their incompatibility in the code
    Adam Fleishaker
    @afleishaker
    I was able to wrap box in a prompt and that worked out. Don't know, but if you scroll up to Jun 2019 it's written here.
    Piotr Murach
    @piotrmurach
    @afleishaker What do you mean by 'returned without printing' ? You can control where the output goes with :output. This means you can redirect it to anything that responds to print message. The :clear option helps you to remove the progress bar when it is done.
    Keil Miller Jr
    @keilmillerjr_gitlab
    Hello. Would it be possibly to invoke an instance of a ruby app remotely? Via web browser? Access tty in a manner of terminal to mainframe.
    Daniel Vartanov
    @DanielVartanov
    @keilmillerjr_gitlab Usage of a browser requires some sort of HTTP server on that side, it's quite cumbersome, but still possible, may be there are open source implementations of that out there already. I don't know your circumstances, but perhaps the easiest way of running a terminal app remotely is SSH
    narutaro
    @narutaro
    Hi let me ask a question:
    I overwrote a command description from "desc A" to "desc B" but it did not work. Am I doing wrong...?
    macbook:app masaino$ ruby -v
    ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-darwin19]
    macbook:app masaino$ teletype -v
    v0.10.0
    macbook:app masaino$ uname -a
    Darwin macbook.local 19.6.0 Darwin Kernel Version 19.6.0: Thu Jun 18 20:49:00 PDT 2020; root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
    
    macbook:app masaino$ teletype add com --desc 'desc A'
          create  spec/integration/com_spec.rb
          create  spec/unit/com_spec.rb
          create  lib/app/commands/com.rb
          create  lib/app/templates/com/.gitkeep
          inject  lib/app/cli.rb
    macbook:app masaino$ teletype add com --desc 'desc B' --force
           force  spec/integration/com_spec.rb
       identical  spec/unit/com_spec.rb
       identical  lib/app/commands/com.rb
       identical  lib/app/templates/com/.gitkeep
    macbook:app masaino$ exe/app
    Commands:
      app com             # desc A
      app help [COMMAND]  # Describe available commands or one specific command
      app version         # app version
    narutaro
    @narutaro
    ah, sorry understand that it doesn't update lib/app/cli.rb
    Piotr Murach
    @piotrmurach
    @narutaro The teletype isn't yet that smart to figure this out, unfortunately. When you come across things that could be improved or have suggestions please post them on the project issues tracker or even better submit a pull request. At the moment I'm updating all tty components and working on the tty itself to provide a bit smoother experience in v0.11.0.
    narutaro
    @narutaro
    @piotrmurach - Thank you!
    Andy Maleh
    @AndyObtiva
    Thank you for the wonderful tty-prompt and tty-screen gems. I just built these TUIs with them: https://github.com/AndyObtiva/rake-tui / https://github.com/AndyObtiva/rvm-tui
    Piotr Murach
    @piotrmurach
    @AndyObtiva That's great!
    Eddy Kim
    @edk11_gitlab
    i came here with a question, but just figured it out. Thanks Piotr for the great libraries, i use them all the time! beats writing everything in choice or curses :)
    Piotr Murach
    @piotrmurach
    @edk11_gitlab That's awesome to hear!
    inyerade
    @inyerade
    Hi @piotrmurach , I have question about tty-option. In https://github.com/piotrmurach/tty-option#2510-validate say Will internally cause an exception TTY::Option::InvalidArgument that will make params invalid. but I execute the same first example and dont get a exception
    inyerade
    @inyerade
    I have to change validate "\d+" with validate /\d+/ and add convert :int and then the validate? command give me false but yet not get the exception
    Piotr Murach
    @piotrmurach
    Hi @inyerade, one of the 'features', as explained in the readme docs, is that "Parsing doesn't raise errors by default and collects issues to allow for better user experience." The sentence that you cited "Will internally cause an exception TTY::Option::InvalidArgument that will make params invalid. " means that inside the TTY::Option the specific error is raised that makes the params invalid but no actual errors are raised. I would suggest reading parse method section and params section. I wrote the Readme to document all the APIs and usage but please free to submit PR if something is missing or not clear enough. I'm keen to make sure the docs are complete and easy to use.
    Jeffrey LI
    @JeffreyArtworks

    help needed: for some reason, I "gem install tty" but don't get "teletype" as a new command.

    effrey@Mac-mini youtube % gem install tty
    Successfully installed tty-0.10.0
    Parsing documentation for tty-0.10.0
    Done installing documentation for tty after 0 seconds
    1 gem installed
    jeffrey@Mac-mini youtube % teletype new app
    zsh: command not found: teletype

    Piotr Murach
    @piotrmurach
    @JeffreyArtworks Unfortunately, this is not an issue related to tty gem. I verified by installing v0.10.0 that the teletype executable works as expected. I'd potentially look into reinstalling Ruby version that you're using. However, this is an issue for yourself to figure out why your system fails to find Ruby installed executables.