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

Command handling implemented #323 #331

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions lib/zold/commands/alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,34 @@ def run(args = [])
mine = Args.new(opts, @log).take || return
command = mine[0]
raise "A command is required, try 'zold alias --help'" unless command
case command
when 'set' then set(mine[1], mine[2])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@botanicus please don't make us guess what mine[1] is, extract variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ledestin it's how it's been used in other commands as well, for instance https://github.com/zold-io/zold/blob/master/lib/zold/commands/remote.rb#L120

If you think this is wrong, then it should be changed everywhere, not just here, in which case I think bug report is where it belongs.

I personally don't think there's anything wrong with it since they are named in both method signature and in the help just above it.

I'm not sure what @yegor256 thinks, I've seen something from him about avoiding unnecessary variables, but I cannot tell if this is one of the cases or not.

Anyhow ... since it's not specific to this code, I'd suggest a bug report. Makes sense?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@botanicus sure!

when 'remove' then remove(mine[1])
when 'show' then show(mine[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else 
  raise “Unknown command: ‘#{command}’”
end

end
end

# @todo #323:30min Implement the set command.
# The set command expects 'wallet' which is the wallet id
# and 'alias' (here called 'name' as alias is a Ruby keyword).
# It writes this info into the alias file as described in #279.
def set(_wallet, _name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@botanicus do tests exist for these?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes #330

raise NotImplementedError, 'This is not yet implemented'
end

# @todo #323:30min Implement the remove command.
# The remove command expect an 'alias' (here called 'name' as alias
# is a Ruby keyword).
# It removes given alias from the alias file as described in #279.
def remove(_name)
raise NotImplementedError, 'This is not yet implemented'
end

# @todo #279:30min Implement command handling. As in other commands,
# there should be case/when command/end loop and commands should be
# implemented as methods.
# @todo #323:30min Implement the show command.
# The show command expect an 'alias' (here called 'name' as alias
# is a Ruby keyword).
# It prints out wallet id corresponding with given alias from the alias file as described in #279.
def show(_name)
raise NotImplementedError, 'This is not yet implemented'
end
end
Expand Down