Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Invisible new space in prompt input #31

Closed
ghost opened this Issue · 4 comments

1 participant

@ghost

I have this code:

program.prompt "folder: ", (folder) ->
  program.prompt "file: ", (file) ->
    console.log folder + "/" + file
    console.log "^ Entered path"

This will print:

my_folder
/my_file

^ Entered path

to the prompt.

There is an invisible new line character after folder and file.

Could this be removed?

@tj
Owner
tj commented

because input is line-buffered, so both folder and file have a newline, you can .trim() them if you want

@tj tj closed this
@ghost

It worked.

But I don't get why you would want a new line as default. That forces everyone to use trim(). Couldn't this be taken care of behind the scenes?

In this way I don't have to have code like this:

program.prompt "name: ", (name) ->
  name = name.trim()
  program.prompt "description: ", (file) ->
    file = file.trim()
    program.prompt "homepage: (*none*) ", (homepage = "0.0.1") ->
      homepage = homepage.trim()
      program.prompt "username: (*github*) ", (username = "0.0.1") ->
        username = username.trim()
        program.prompt "author: ", (author) ->
          author = author.trim()
          program.prompt "email: ", (email) ->
            email = email.trim()
            program.prompt "url: ", (url) ->
@tj
Owner
tj commented

true, I suppose we could do that :)

@ghost

wiiiii!

@jonrohan jonrohan referenced this issue from a commit in botriot/commander.js
@tj Fixed: line-buffered input automatically trimmed. Closes #31 9745551
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.