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

Improve error when calling license_finder approve without naming a dependency #91

Merged
merged 1 commit into from Apr 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 10 additions & 11 deletions lib/license_finder/cli.rb
Expand Up @@ -90,7 +90,8 @@ def list
end

desc "add LICENSE...", "Add one or more licenses to the whitelist"
def add(*licenses)
def add(license, *other_licenses)
licenses = other_licenses.unshift license
modifying {
licenses.each do |license|
LicenseFinder.config.whitelist.push(license)
Expand All @@ -100,7 +101,8 @@ def add(*licenses)
end

desc "remove LICENSE...", "Remove one or more licenses from the whitelist"
def remove(*licenses)
def remove(license, *other_licenses)
licenses = other_licenses.unshift license
modifying {
licenses.each do |license|
LicenseFinder.config.whitelist.delete(license)
Expand Down Expand Up @@ -165,16 +167,13 @@ def rescan
method_option :approver, desc: "The person granting the approval"
method_option :message, desc: "The reason for the approval"
desc "approve DEPENDENCY_NAME... [--approver APPROVER_NAME] [--message APPROVAL_MESSAGE]", "Approve one or more dependencies by name, optionally storing who approved the dependency and why"
def approve(*names)
if(names.count < 1)
say "Warning: Must specify dependencies to approve.", :red
else
die_on_error {
names.each { |name| DependencyManager.approve!(name, options[:approver], options[:message]) }
}
def approve(name, *other_names)
names = other_names.unshift name
die_on_error {
names.each { |name| DependencyManager.approve!(name, options[:approver], options[:message]) }
}

say "The #{names.join(", ")} dependency has been approved!", :green
end
say "The #{names.join(", ")} dependency has been approved!", :green
end

desc "license LICENSE DEPENDENCY_NAME", "Update a dependency's license"
Expand Down
4 changes: 1 addition & 3 deletions spec/lib/license_finder/cli_spec.rb
Expand Up @@ -211,9 +211,7 @@ module CLI
DependencyManager.should_not_receive(:approve!)

silence_stdout do
subject.should_receive(:say).with(/Warning/, :red)
subject.should_not_receive(:say).with(/dependency has been approved/, anything)
subject.approve
expect { subject.approve }.to raise_error(ArgumentError)
end
end

Expand Down