Skip to content

Commit

Permalink
Make aliases work again Closes: #93 (#114)
Browse files Browse the repository at this point in the history
* Make aliases work again Closes: #93

* show usage when args are insufficient

* Update lib/twurl/cli.rb

Co-Authored-By: Shohei Maeda <[email protected]>
  • Loading branch information
flaviomartins and smaeda-ks committed Dec 10, 2019
1 parent ded1136 commit 5a7cee4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/twurl/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ def dispatch(options)
end

def parse_options(args)
arguments = args.dup

Twurl.options = Options.new
Twurl.options.args = arguments
Twurl.options.args = args.dup
Twurl.options.trace = false
Twurl.options.data = {}
Twurl.options.headers = {}
Expand Down Expand Up @@ -97,13 +95,13 @@ def parse_options(args)
arguments = option_parser.parse!(args)
Twurl.options.command = extract_command!(arguments)
Twurl.options.path = extract_path!(arguments)

if Twurl.options.command == DEFAULT_COMMAND and Twurl.options.path.nil?
Twurl.options.subcommands = arguments

if Twurl.options.command == DEFAULT_COMMAND and Twurl.options.path.nil? and Twurl.options.args.empty?
CLI.puts option_parser
raise NoPathFound, "No path found"
end

Twurl.options.subcommands = arguments
Twurl.options
end

Expand Down

0 comments on commit 5a7cee4

Please sign in to comment.