Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invisible new space in prompt input #31

Closed
ghost opened this issue Nov 24, 2011 · 4 comments
Closed

Invisible new space in prompt input #31

ghost opened this issue Nov 24, 2011 · 4 comments

Comments

@ghost
Copy link

ghost commented Nov 24, 2011

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
Copy link
Owner

tj commented Nov 24, 2011

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

@tj tj closed this as completed Nov 24, 2011
@ghost
Copy link
Author

ghost commented Nov 24, 2011

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
Copy link
Owner

tj commented Nov 24, 2011

true, I suppose we could do that :)

@ghost
Copy link
Author

ghost commented Nov 24, 2011

wiiiii!

jonrohan pushed a commit to botriot/commander.js that referenced this issue Aug 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant