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
    @nivpgir Currently there is no way, tty-prompt was developed much earlier than tty-box and cannot be absolutely positioned inside terminal to allow it to be wrapped inside a box.
    nivpgir
    @nivpgir
    I see, I've moved on from it anyways, but thanks
    Ben
    @benjamin-hull
    Hey folks ... I've hit what I think is a simple snag working with tty-table for the first time: I'm trying to show the first few rows of a loaded CSV in a table. Everything seems to work fine, except that render yields... nothing
    If I pause within the script, between table creation and render, and then call render myself, I get a string with what looks the table in it as the response, but nothing is actually output to the terminal. This is within a rake task.
    Am I missing something obvious?
    Ben
    @benjamin-hull
    So yeah, it was kinda obvious: you gotta puts if you want to puts! :)
    Piotr Murach
    @piotrmurach
    @benjamin-hull That was on purpose to allow greater flexibility. The table gets rendered to whatever you decide, this can be standard terminal stream or a file. The tty gems main focus is terminal but really they have wider applicability in different contexts.
    matheussilvasantos
    @matheussilvasantos
    Hello, how can I use teletype without adding a command?
    I would like to make an app like ls or mkdir that we call without passing a command.
    Piotr Murach
    @piotrmurach
    @matheussilvasantos I would generate a new gem with teletype and add command, so for example, you get mkdir create and then in cli.rb use default_command :create to instruct your binary to run create command when no command is provided. It's a bit roundabout way but it should work and gives you benefits of writing tests and more.
    Tay Kang Sheng
    @TayKangSheng

    Hello. I found a behaviour about default option for multiline input in tty-prompt and am wondering whether this is deliberate? In the spec, it states that the returned value for a multiline question with default option enabled returns an empty array. If this is deliberate, can I know what is the rationale behind this design?

    https://github.com/piotrmurach/tty-prompt/blob/master/spec/unit/multiline_spec.rb#L19

    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