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

Won't run from CLI - bad option name files #1583

Closed
remorse opened this issue Nov 1, 2018 · 7 comments
Closed

Won't run from CLI - bad option name files #1583

remorse opened this issue Nov 1, 2018 · 7 comments

Comments

@remorse
Copy link

remorse commented Nov 1, 2018

Hi! I tried using js-beautify this morning and got an error. I've updated to version 1.8.8, but I still get an error.

$ js-beautify --file=foo.js
js-beautify@1.8.8

CLI Options:
  -f, --file       Input file(s) (Pass '-' for stdin)
  -r, --replace    Write output in-place, replacing input
  -o, --outfile    Write output to file (default stdout)
  --config         Path to config file
  --type           [js|css|html] ["js"]
  -q, --quiet      Suppress logging to stdout
  -h, --help       Show this help
  -v, --version    Show the version

Beautifier Options:
  -s, --indent-size                 Indentation size [4]
  -c, --indent-char                 Indentation character [" "]
  -t, --indent-with-tabs            Indent with tabs, overrides -s and -c
  -e, --eol                         Character(s) to use as line terminators.
                                    [first newline in file, otherwise "\n]
  -n, --end-with-newline            End output with newline
  --editorconfig                    Use EditorConfig to set up the options
  -l, --indent-level                Initial indentation level [0]
  -p, --preserve-newlines           Preserve line-breaks (--no-preserve-newlines disables)
  -m, --max-preserve-newlines       Number of line-breaks to be preserved in one chunk [10]
  -P, --space-in-paren              Add padding spaces within paren, ie. f( a, b )
  -E, --space-in-empty-paren        Add a single space inside empty paren, ie. f( )
  -j, --jslint-happy                Enable jslint-stricter mode
  -a, --space-after-anon-function   Add a space before an anonymous function's parens, ie. function ()
  --space_after_named_function      Add a space before a named function's parens, ie. function example ()
  -b, --brace-style                 [collapse|expand|end-expand|none][,preserve-inline] [collapse,preserve-inline]
  -u, --unindent-chained-methods    Don't indent chained method calls
  -B, --break-chained-methods       Break chained method calls across subsequent lines
  -k, --keep-array-indentation      Preserve array indentation
  -x, --unescape-strings            Decode printable characters encoded in xNN notation
  -w, --wrap-line-length            Wrap lines at next opportunity after N characters [0]
  -X, --e4x                         Pass E4X xml literals through untouched
  --good-stuff                      Warm the cockles of Crockford's heart
  -C, --comma-first                 Put commas at the beginning of new line instead of end
  -O, --operator-position           Set operator position (before-newline|after-newline|preserve-newline) [before-newline]
Error: indent_level was invalid with value "--eol"

This happens regardless of what options I try to pass. I've added the "indent-level" option, and the "eol" option, but it doesn't work.

I think there is some sort of error in the options parsing?

My usual use case is in a pipeline, with a bunch of options passed, but I was able to get rid of all of them (as you can see above), and it's still an issue.

@bitwiseman
Copy link
Member

try js-beautify --file foo.js

@remorse
Copy link
Author

remorse commented Nov 1, 2018

Same problem (I had already tried that, actually, but I re-ran it just to be sure)...

$ js-beautify --file foo.js
js-beautify@1.8.8

CLI Options:
  -f, --file       Input file(s) (Pass '-' for stdin)
  -r, --replace    Write output in-place, replacing input
  -o, --outfile    Write output to file (default stdout)
  --config         Path to config file
  --type           [js|css|html] ["js"]
  -q, --quiet      Suppress logging to stdout
  -h, --help       Show this help
  -v, --version    Show the version

Beautifier Options:
  -s, --indent-size                 Indentation size [4]
  -c, --indent-char                 Indentation character [" "]
  -t, --indent-with-tabs            Indent with tabs, overrides -s and -c
  -e, --eol                         Character(s) to use as line terminators.
                                    [first newline in file, otherwise "\n]
  -n, --end-with-newline            End output with newline
  --editorconfig                    Use EditorConfig to set up the options
  -l, --indent-level                Initial indentation level [0]
  -p, --preserve-newlines           Preserve line-breaks (--no-preserve-newlines disables)
  -m, --max-preserve-newlines       Number of line-breaks to be preserved in one chunk [10]
  -P, --space-in-paren              Add padding spaces within paren, ie. f( a, b )
  -E, --space-in-empty-paren        Add a single space inside empty paren, ie. f( )
  -j, --jslint-happy                Enable jslint-stricter mode
  -a, --space-after-anon-function   Add a space before an anonymous function's parens, ie. function ()
  --space_after_named_function      Add a space before a named function's parens, ie. function example ()
  -b, --brace-style                 [collapse|expand|end-expand|none][,preserve-inline] [collapse,preserve-inline]
  -u, --unindent-chained-methods    Don't indent chained method calls
  -B, --break-chained-methods       Break chained method calls across subsequent lines
  -k, --keep-array-indentation      Preserve array indentation
  -x, --unescape-strings            Decode printable characters encoded in xNN notation
  -w, --wrap-line-length            Wrap lines at next opportunity after N characters [0]
  -X, --e4x                         Pass E4X xml literals through untouched
  --good-stuff                      Warm the cockles of Crockford's heart
  -C, --comma-first                 Put commas at the beginning of new line instead of end
  -O, --operator-position           Set operator position (before-newline|after-newline|preserve-newline) [before-newline]
Error: indent_level was invalid with value "--eol"

@bitwiseman
Copy link
Member

Error: indent_level was invalid with value "--eol" ... What?

What environment are you running this in? Maybe come over to gitter and we can chat.

@remorse
Copy link
Author

remorse commented Nov 1, 2018

Hi! Mac OS X 10.13.6, with node installed via homebrew, and at version 11.0.0 (although it was happening with an earlier version as well; I updated node and js-beautify in an attempt to solve the problem.

What is gitter?

@bitwiseman
Copy link
Member

@remorse
Copy link
Author

remorse commented Nov 2, 2018

Sorry -- I missed your message last night. I have signed in this morning, if you are still interested/available...

@remorse
Copy link
Author

remorse commented Nov 2, 2018

I worked with @bitwiseman on Gitter, and the problem is that the long-form of the argument is now --files, not --file.

Either the help message needs to be updated, or the argument parsing code needs to be fixed to recognize --file (or maybe it should recognize both?).

Thanks muchly,
Ricky

@bitwiseman bitwiseman changed the title Won't run from CLI Won't run from CLI - bad option name files Dec 6, 2018
@bitwiseman bitwiseman added this to the v1.8.x milestone Dec 6, 2018
@bitwiseman bitwiseman modified the milestones: v1.8.x, v1.8.9 Dec 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants