Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Samuel Williams
    @ioquatix
    @fwolfst I think you've misunderstood how it works.
    @fwolfst I believe the command is basically the same as system(...). If you specify one string, it gets executed using the shell. If you provide multiple arguments, they get provided to the OS level execve.
    Felix Wolfsteller
    @fwolfst
    @ioquatix yes. I was asking if an extension makes sense and if we should discuss API details for that, so that it can overcome the execve conventions. Or am I still misunderstanding something?
    Samuel Williams
    @ioquatix
    I'm not sure why cmd.run(:mysql, *["--password=#{'mypass']") is escaping the = that seems very wrong to me
    system("mysql", "-e", "SHOW TABLES") should work just fine
    execve shouldn't be touching the args, they are passed directly through to the child process
    Viet (Drake) Tran
    @tiev
    @piotrmurach Is there any gem to help open the editor to edit a content and get result when quit the editor? Similar with how we can edit commit messages
    I saw the tty-editor but seems it cannot do that
    Viet (Drake) Tran
    @tiev
    ahh, I've figured it out, just when the editor is exited, we can get the changed file
    nivpgir
    @nivpgir
    hi, is there a way to make a prompt work inside a box? I tried the trivial: box = TTY::Box.frame(width: 30, height: 10) {prompt.multi_select("Select drinks?", choices)}, and it crashed
    ok I actually get why it crashed, the content of the block should evaluate to a string (duh....) but my question stands, is there a way?
    Minh
    @minhl337
    how do i ask users for a date and set a reminder like (yyyy-mm-dd)?
    Danny Wakeling
    @Dwake5
    Hello. Im making a CLI choose your own adventure. Is there a library/gem on here for making a constant top bar to which I can display stats in?
    Viet (Drake) Tran
    @tiev
    @Minh input for each field separately
    @Dwake5 you must get terminal size and draw box for the whole terminal. Tty has thay two features
    Piotr Murach
    @piotrmurach
    @Dwake5 You can use tty-box to draw a status box and center it with tty-screen.
    Piotr Murach
    @piotrmurach

    @minhl337 One way I can think of doing this:

    prompt = TTY::Prompt.new
    prompt.ask("Date of birth (yyyy-mm-dd)?") do |q|
      q.validate(/\A\d{4}-d{2}-d{2}\Z/)
      q.messages[:valid?] = "Invalid date format"
      q.convert :datetime
    end

    This will validate correct format and convert the input into DateTime for you.

    @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.
    Matheus Silva Santos de Oliveira
    @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
    Kenney G
    @Kenney-G
    Hi, I'm just trying to figure out how to set it up so that after a user makes a choice it doesn't exit, but presents the main menu again. I have methods for the prompt.select options, but I'm having trouble looping them back into the main menu so that the user can keep using the app.
    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?