Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Invisible new space in prompt input #31

ghost opened this Issue · 4 comments

1 participant


I have this code:

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

This will print:


^ Entered path

to the prompt.

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

Could this be removed?

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

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 commented

true, I suppose we could do that :)



@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.