-
Notifications
You must be signed in to change notification settings - Fork 29
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
Restructure commands: Adding get subcommands (WIP) #195
Conversation
I would keep it simple for now and not introduce a new namespace or rename the command class. You could just add a new class Calling private methods from outside of a class is usually not a great idea. They are private for a reason after all. Maybe you can find a better way? The existing Regarding the tests I would not use VCR anymore. #193 will remove them. For the command line handling it might be best to not rely on any board data and only test that the logic of handling the commands works properly. |
I understand the problem with a new namespace but it was created to fulfill the problem with the @@settings and the private methods, because they need to be available from any classes on that namespace. so that methods are not that private at all when introducing new classes. I will search for a better way, but I'm not sure what is the best way to share these methods and variables around these new classes. |
@matheussbernardo regarding the Making |
Actually @Ana06 I dont think inherit from Cli makes sense because the Cli class has public methods that I do not want to inherit, and the thor documentation uses the subcommands as subclasses from Thor. |
I thought about introducing a new module that implements
Or maybe use ruby open classes and include the new module on the Thor class so that all the subcommands and Cli get the methods that is needed |
@cornelius @Ana06 What do you guys think about the module? |
@matheussbernardo the idea sounds go to me, @cornelius what do you think? |
Yes, a module sounds good. Give it a try. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matheussbernardo you need to rebase
lib/cli.rb
Outdated
@@ -408,7 +57,229 @@ def require_trello_credentials | |||
# Returns the board_id using id_or_alias. If id_or_alias matches a mapping | |||
# from trollolorc then the mapped id is returned or else the id_or_alias | |||
# is returned. | |||
def board_id(id_or_alias) | |||
def self.board_id(id_or_alias) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method was private before and now it is public 🤔
lib/cli.rb
Outdated
write_back = false | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra spaces that can be removed 😉
lib/cli.rb
Outdated
@@settings.verbose = options[:verbose] | ||
@@settings.raw = options[:raw] | ||
end | ||
|
||
def require_trello_credentials | ||
def self.require_trello_credentials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method was private before and now it is public 🤔
lib/cli.rb
Outdated
class_option :version, type: :boolean, desc: 'Show version' | ||
class_option :verbose, type: :boolean, desc: 'Verbose mode' | ||
class_option :raw, type: :boolean, desc: 'Raw mode' | ||
# class_option 'board-id', type: :string, desc: 'id of Trello board' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this comment here?
lib/cli.rb
Outdated
class_option :verbose, type: :boolean, desc: 'Verbose mode' | ||
class_option :raw, type: :boolean, desc: 'Raw mode' | ||
# class_option 'board-id', type: :string, desc: 'id of Trello board' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too many empty lines 🙈
lib/cli.rb
Outdated
def self.settings=(s) | ||
@@settings = s | ||
end | ||
# class_option 'board-id', type: :string, desc: 'id of Trello board' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't leave in code which has been commented out.
The code in general looks fine now but please rebase as Ana suggested so we can also see the CI run. |
54e59cc
to
9e685b6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please prepare the commits to be merged with a description. 😉
.rubocop_todo.yml
Outdated
@@ -96,6 +96,7 @@ Layout/ExtraSpacing: | |||
Layout/IndentHeredoc: | |||
Exclude: | |||
- 'lib/cli.rb' | |||
- 'spec/unit/cli/*.rb' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can do this automatically by running: rubocop --auto-gen-conf
1301cc9
to
a2c5f6f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @cornelius please take a look 😉
In general the patch looks great now. I would suggest to slightly change the naming of the classes, though, to get a more consistent naming scheme. Sorry, if that feels like nitpicking but it's easier to do this before things are merged and so we get a clean state in master right away. I would name all the CLI classes with a It should be And there seems to be a test failing in the CI. This should also be fixed. |
* Use Thor subcommands and creates new classes for each new subcommand * Change commands name to be more expressive * Change tests to reflect the changes
looks good to me. please merge when the ci is green. |
Ready to merge! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then let's merge it! 😉
Hello @Ana06 @cornelius,
I started to implement the new commands,
I faced a big problem with the tests. I do not fully understand them, It does not seem to have a pattern between all the tests, some use VCR, other mock in a way others in another away, I need help on that.
Regarding the changes I propose a different structure.
According to the thor docs(http://whatisthor.com/) if I want to implement subcommands like (trollolo get SUBCOMMANDS), I need to create another class that inherits from Thor and then point that class from the parent class and wrap everything around the same module.
So basically what I did was, I created a module name TrolloloCLI on
cli.rb
, then I created a dir named cli and created a class inside named Get, I copied to this new class all the get related commands and renamed it to what was defined on #15.On the
cli.rb
file I require thecli/get.rb
, also I had to call some methods that were private on the class Cli because of that I changed these methods to be module methods and the @@settings to be a variable of the module, this way I can call them from the new class Get and in the future from the others classes that I intend to do.What do you guys think? Is this a good way to do the restructure? And about the tests how can I understand them fully and maybe cleanup the test suite? (seems that @manno is working on that #193 PR)