Class: JsxRosetta::CLI
- Inherits:
-
Object
- Object
- JsxRosetta::CLI
- Defined in:
- lib/jsx_rosetta/cli.rb
Overview
Command-line interface for the gem.
Subcommands:
install npm-install the Node sidecar dependencies.
translate FILE [-o DIR] JSX/TSX → ViewComponent files written to DIR
(default: current directory). TSX is detected
via the .tsx extension or --tsx.
parse FILE Print the parsed Babel AST as pretty JSON.
version Print the gem version.
help Show usage.
Constant Summary collapse
- EXIT_OK =
0- EXIT_USAGE =
64- EXIT_FAILURE =
1
Instance Method Summary collapse
-
#initialize(argv = ARGV.dup, stdout: $stdout, stderr: $stderr) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(argv = ARGV.dup, stdout: $stdout, stderr: $stderr) ⇒ CLI
Returns a new instance of CLI.
25 26 27 28 29 |
# File 'lib/jsx_rosetta/cli.rb', line 25 def initialize(argv = ARGV.dup, stdout: $stdout, stderr: $stderr) @argv = argv @stdout = stdout @stderr = stderr end |
Instance Method Details
#run ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/jsx_rosetta/cli.rb', line 31 def run command = @argv.shift case command when "install" then run_install when "translate" then run_translate when "routes" then run_routes when "parse" then run_parse when "version", "-v", "--version" then run_version when nil, "help", "-h", "--help" then print_help(EXIT_OK) else @stderr.puts "jsx_rosetta: unknown command: #{command.inspect}" print_help(EXIT_USAGE) end end |