Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: bc412dc3ab37
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3ff8e593544c
Choose a head ref
  • 3 commits
  • 1 file changed
  • 2 contributors

Commits on Oct 5, 2017

  1. Copy the full SHA
    0847c7e View commit details
  2. Copy the full SHA
    ddf8a18 View commit details

Commits on Oct 14, 2017

  1. Merge pull request #5080 from j8r/if-clean

    Integrate the "if" conditions into the "case" expressions
    asterite authored Oct 14, 2017
    Copy the full SHA
    3ff8e59 View commit details
Showing with 67 additions and 77 deletions.
  1. +67 −77 src/compiler/crystal/command.cr
144 changes: 67 additions & 77 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
@@ -58,58 +58,50 @@ class Crystal::Command

def run
command = options.first?

if command
case
when "init".starts_with?(command)
options.shift
init
when "build".starts_with?(command), "compile".starts_with?(command)
if "compile".starts_with?(command)
STDERR.puts "Deprecation: The compile command was renamed to build and will be removed in a future version."
end
options.shift
build
when "play".starts_with?(command)
options.shift
playground
when "deps".starts_with?(command)
options.shift
deps
when "docs".starts_with?(command)
options.shift
docs
when command == "env"
options.shift
env
when command == "eval"
options.shift
eval
when "run".starts_with?(command)
options.shift
run_command(single_file: false)
when "spec/".starts_with?(command)
options.shift
spec
when "tool".starts_with?(command)
options.shift
tool
when "help".starts_with?(command), "--help" == command, "-h" == command
puts USAGE
exit
when "version".starts_with?(command), "--version" == command, "-v" == command
puts Crystal::Config.description
exit
else
if File.file?(command)
run_command(single_file: true)
else
error "unknown command: #{command}"
end
end
else
case
when !command
puts USAGE
exit
when "init".starts_with?(command)
options.shift
init
when "build".starts_with?(command)
options.shift
build
when "play".starts_with?(command)
options.shift
playground
when "deps".starts_with?(command)
options.shift
deps
when "docs".starts_with?(command)
options.shift
docs
when command == "env"
options.shift
env
when command == "eval"
options.shift
eval
when "run".starts_with?(command)
options.shift
run_command(single_file: false)
when "spec/".starts_with?(command)
options.shift
spec
when "tool".starts_with?(command)
options.shift
tool
when "help".starts_with?(command), "--help" == command, "-h" == command
puts USAGE
exit
when "version".starts_with?(command), "--version" == command, "-v" == command
puts Crystal::Config.description
exit
when File.file?(command)
run_command(single_file: true)
else
error "unknown command: #{command}"
end
rescue ex : Crystal::LocationlessException
error ex.message
@@ -134,35 +126,33 @@ class Crystal::Command

private def tool
tool = options.first?
if tool
case
when "context".starts_with?(tool)
options.shift
context
when "format".starts_with?(tool)
options.shift
format
when "expand".starts_with?(tool)
options.shift
expand
when "hierarchy".starts_with?(tool)
options.shift
hierarchy
when "implementations".starts_with?(tool)
options.shift
implementations
when "types".starts_with?(tool)
options.shift
types
when "--help" == tool, "-h" == tool
puts COMMANDS_USAGE
exit
else
error "unknown tool: #{tool}"
end
else
case
when !tool
puts COMMANDS_USAGE
exit
when "context".starts_with?(tool)
options.shift
context
when "format".starts_with?(tool)
options.shift
format
when "expand".starts_with?(tool)
options.shift
expand
when "hierarchy".starts_with?(tool)
options.shift
hierarchy
when "implementations".starts_with?(tool)
options.shift
implementations
when "types".starts_with?(tool)
options.shift
types
when "--help" == tool, "-h" == tool
puts COMMANDS_USAGE
exit
else
error "unknown tool: #{tool}"
end
end