Skip to content

Use wrappers around action methods to handle quiet/pretend invocation of commands #75

@nickserv

Description

@nickserv

Here's an example of running grep say_status lib/homesick/actions.rb on homesick's source.

say_status 'git clone', "#{repo} to #{destination.expand_path}", :green unless options[:quiet]
say_status :exist, destination.expand_path, :blue unless options[:quiet]
say_status 'git init', '' unless options[:quiet]
say_status 'git init', 'already initialized', :blue unless options[:quiet]
say_status 'git remote', "add #{name} #{url}" unless options[:quiet]
# about 20 lines removed for brevity

The quiet and pretend options are often checked manually, which leads to fairly complex looking code.

Instead, I think it would be cleaner to use methods that handle quiet/pretend invocation for us. I vaguely remember seeing something in Thor's source code about a quiet? getter method that is used in say_status, but I couldn't figure out how to set this yet. It would be nice to use features built into Thor if there are any for this, but worst case we can add our own wrapper methods.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions