Skip to content
This repository has been archived by the owner on Jun 22, 2020. It is now read-only.

Commit

Permalink
knife sub-command help now shows complete knife command
Browse files Browse the repository at this point in the history
Remove the "Sub-command:" prefix, replace it with "knife"
  • Loading branch information
Seth Falcon authored and danielsdeleo committed Jul 15, 2010
1 parent 6d00e47 commit 645622c
Show file tree
Hide file tree
Showing 61 changed files with 75 additions and 71 deletions.
24 changes: 14 additions & 10 deletions chef/lib/chef/knife.rb
Expand Up @@ -29,6 +29,10 @@ class Knife

attr_accessor :name_args

def self.msg(msg)
puts msg
end

# Load all the sub-commands
def self.load_commands
@sub_classes = Hash.new
Expand All @@ -44,7 +48,7 @@ def self.load_commands

def self.list_commands
load_commands
puts "SUB-COMMANDS (for details, knife SUBCMD --help)\n\n"
puts "Available SUB-COMMANDS (for details, knife SUB-COMMAND --help)\n\n"
ch = Hash.new { |h, k| h[k] = [] }
@sub_classes.keys.sort.each do |c|
k = c
Expand Down Expand Up @@ -91,7 +95,7 @@ def self.find_command(args=ARGV, merge_opts={})
end

unless klass_instance
puts "Cannot find sub command for: #{args.join(' ')}"
puts "Cannot find sub-command for: #{args.join(' ')}"
Chef::Knife.list_commands
exit 10
end
Expand Down Expand Up @@ -149,7 +153,7 @@ def configure_chef
Chef::Config.from_file(config[:config_file])
else
# ...but do log a message if no config was found.
Chef::Log.info("No knife configuration file found")
self.msg("No knife configuration file found")
end

Chef::Config[:log_level] = config[:log_level] if config[:log_level]
Expand Down Expand Up @@ -253,11 +257,11 @@ def confirm(question, append_instructions=true)
when "Y", "y"
true
when "N", "n"
Chef::Log.info("You said no, so I'm done here.")
self.msg("You said no, so I'm done here.")
exit 3
else
Chef::Log.error("I have no idea what to do with #{answer}")
Chef::Log.error("Just say Y or N, please.")
self.msg("I have no idea what to do with #{answer}")
self.msg("Just say Y or N, please.")
confirm(question)
end
end
Expand Down Expand Up @@ -312,7 +316,7 @@ def edit_object(klass, name)

output.save

Chef::Log.info("Saved #{output}")
self.msg("Saved #{output}")

output(format_for_display(object)) if config[:print_after]
end
Expand All @@ -328,7 +332,7 @@ def create_object(object, pretty_name=nil, &block)

pretty_name ||= output

Chef::Log.info("Created (or updated) #{pretty_name}")
self.msg("Created (or updated) #{pretty_name}")

output(output) if config[:print_after]
end
Expand All @@ -346,7 +350,7 @@ def delete_object(klass, name, delete_name=nil, &block)
output(format_for_display(object)) if config[:print_after]

obj_name = delete_name ? "#{delete_name}[#{name}]" : object
Chef::Log.warn("Deleted #{obj_name}!")
self.msg("Deleted #{obj_name}!")
end

def bulk_delete(klass, fancy_name, delete_name=nil, list=nil, regex=nil, &block)
Expand All @@ -373,7 +377,7 @@ def bulk_delete(klass, fancy_name, delete_name=nil, list=nil, regex=nil, &block)
object.destroy
end
output(format_for_display(object)) if config[:print_after]
Chef::Log.warn("Deleted #{fancy_name} #{name}")
self.msg("Deleted #{fancy_name} #{name}")
end
end

Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/bootstrap.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class Bootstrap < Knife

banner "Sub-Command: knife bootstrap FQDN [RUN LIST...] (options)"
banner "knife bootstrap FQDN [RUN LIST...] (options)"

option :ssh_user,
:short => "-x USERNAME",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_bulk_delete.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class ClientBulkDelete < Knife

banner "Sub-Command: client bulk delete REGEX (options)"
banner "knife client bulk delete REGEX (options)"

def run
if @name_args.length < 1
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_create.rb
Expand Up @@ -35,7 +35,7 @@ class ClientCreate < Knife
:description => "Create the client as an admin",
:boolean => true

banner "Sub-Command: client create CLIENT (options)"
banner "knife client create CLIENT (options)"

def run
@client_name = @name_args[0]
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_delete.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class ClientDelete < Knife

banner "Sub-Command: client delete CLIENT (options)"
banner "knife client delete CLIENT (options)"

def run
@client_name = @name_args[0]
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_edit.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class ClientEdit < Knife

banner "Sub-Command: client edit CLIENT (options)"
banner "knife client edit CLIENT (options)"

def run
@client_name = @name_args[0]
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_list.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class ClientList < Knife

banner "Sub-Command: client list (options)"
banner "knife client list (options)"

option :with_uri,
:short => "-w",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_reregister.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class ClientReregister < Knife

banner "Sub-Command: client reregister CLIENT (options)"
banner "knife client reregister CLIENT (options)"

option :file,
:short => "-f FILE",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/client_show.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class ClientShow < Knife

banner "Sub-Command: client show CLIENT (options)"
banner "knife client show CLIENT (options)"

option :attribute,
:short => "-a ATTR",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/configure.rb
Expand Up @@ -24,7 +24,7 @@ class Configure < Knife
attr_reader :chef_server, :new_client_name, :admin_client_name, :admin_client_key
attr_reader :chef_repo, :new_client_key, :validation_client_name, :validation_key

banner "Sub-Command: configure (options)"
banner "knife configure (options)"

option :repository,
:short => "-r REPO",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_bulk_delete.rb
Expand Up @@ -26,7 +26,7 @@ class CookbookBulkDelete < Knife

option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store'

banner "Sub-Command: cookbook bulk delete REGEX (options)"
banner "knife cookbook bulk delete REGEX (options)"

def run
unless regex_str = @name_args.first
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_delete.rb
Expand Up @@ -26,7 +26,7 @@ class CookbookDelete < Knife

option :purge, :short => '-p', :long => '--purge', :boolean => true, :description => 'Permanently remove files from backing data store'

banner "Sub-Command: cookbook delete COOKBOOK VERSION (options)"
banner "knife cookbook delete COOKBOOK VERSION (options)"

def run
confirm("Files that are common to multiple cookbooks are shared, so purging the files may disable other cookbooks. Are you sure you want to purge files instead of just deleting the cookbook") if config[:purge]
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_download.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class CookbookDownload < Knife

banner "Sub-Command: cookbook download COOKBOOK [VERSION] (options)"
banner "knife cookbook download COOKBOOK [VERSION] (options)"

option :latest,
:short => "-N",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_list.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class CookbookList < Knife

banner "Sub-Command: cookbook list (options)"
banner "knife cookbook list (options)"

option :with_uri,
:short => "-w",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_metadata.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class CookbookMetadata < Knife

banner "Sub-Command: cookbook metadata COOKBOOK (options)"
banner "knife cookbook metadata COOKBOOK (options)"

option :cookbook_path,
:short => "-o PATH:PATH",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_metadata_from_file.rb
Expand Up @@ -25,7 +25,7 @@ class Chef
class Knife
class CookbookMetadataFromFile < Knife

banner "Sub-Command: cookbook metadata from FILE (options)"
banner "knife cookbook metadata from FILE (options)"

def run
file = @name_args[0]
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_show.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class CookbookShow < Knife

banner "Sub-Command: cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)"
banner "knife cookbook show COOKBOOK [VERSION] [PART] [FILENAME] (options)"

option :fqdn,
:short => "-f FQDN",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_site_download.rb
Expand Up @@ -23,7 +23,7 @@ class CookbookSiteDownload < Knife

attr_reader :version

banner "Sub-Command: cookbook site download COOKBOOK [VERSION] (options)"
banner "knife cookbook site download COOKBOOK [VERSION] (options)"

option :file,
:short => "-f FILE",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_site_list.rb
Expand Up @@ -22,7 +22,7 @@ class Chef
class Knife
class CookbookSiteList < Knife

banner "Sub-Command: cookbook site list (options)"
banner "knife cookbook site list (options)"

option :with_uri,
:short => "-w",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_site_search.rb
Expand Up @@ -21,7 +21,7 @@ class Chef
class Knife
class CookbookSiteSearch < Knife

banner "Sub-Command: cookbook site search QUERY (options)"
banner "knife cookbook site search QUERY (options)"

def run
output(search_cookbook(name_args[0]))
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_site_show.rb
Expand Up @@ -21,7 +21,7 @@ class Chef
class Knife
class CookbookSiteShow < Knife

banner "Sub-Command: cookbook site show COOKBOOK [VERSION] (options)"
banner "knife cookbook site show COOKBOOK [VERSION] (options)"

def run
case @name_args.length
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_site_vendor.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class CookbookSiteVendor < Knife

banner "Sub-Command: cookbook site vendor COOKBOOK [VERSION] (options)"
banner "knife cookbook site vendor COOKBOOK [VERSION] (options)"

option :deps,
:short => "-d",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_test.rb
Expand Up @@ -25,7 +25,7 @@ class Chef
class Knife
class CookbookTest < Knife

banner "Sub-Command: cookbook test [COOKBOOKS...] (options)"
banner "knife cookbook test [COOKBOOKS...] (options)"

option :cookbook_path,
:short => "-o PATH:PATH",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/cookbook_upload.rb
Expand Up @@ -32,7 +32,7 @@ class Knife
class CookbookUpload < Knife
include Chef::Mixin::ShellOut

banner "Sub-Command: cookbook upload [COOKBOOKS...] (options)"
banner "knife cookbook upload [COOKBOOKS...] (options)"

option :cookbook_path,
:short => "-o PATH:PATH",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/data_bag_create.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class DataBagCreate < Knife

banner "Sub-Command: data bag create BAG [ITEM] (options)"
banner "knife data bag create BAG [ITEM] (options)"

def run
@data_bag_name, @data_bag_item_name = @name_args
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/data_bag_delete.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class DataBagDelete < Knife

banner "Sub-Command: data bag delete BAG [ITEM] (options)"
banner "knife data bag delete BAG [ITEM] (options)"

def run
if @name_args.length == 2
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/data_bag_edit.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class DataBagEdit < Knife

banner "Sub-Command: data bag edit BAG ITEM (options)"
banner "knife data bag edit BAG ITEM (options)"

def run
if @name_args.length != 2
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/data_bag_from_file.rb
Expand Up @@ -24,7 +24,7 @@ class Chef
class Knife
class DataBagFromFile < Knife

banner "Sub-Command: data bag from file BAG FILE (options)"
banner "knife data bag from file BAG FILE (options)"

def run
updated = load_from_file(Chef::DataBagItem, @name_args[1], @name_args[0])
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/data_bag_list.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class DataBagList < Knife

banner "Sub-Command: data bag list (options)"
banner "knife data bag list (options)"

option :with_uri,
:short => "-w",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/data_bag_show.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class DataBagShow < Knife

banner "Sub-Command: data bag show BAG [ITEM] (options)"
banner "knife data bag show BAG [ITEM] (options)"

def run
display = case @name_args.length
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/ec2_instance_data.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class Ec2InstanceData < Knife

banner "Sub-Command: ec2 instance data [RUN LIST...] (options)"
banner "knife ec2 instance data [RUN LIST...] (options)"

option :edit,
:short => "-e",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/ec2_server_create.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class Ec2ServerCreate < Knife

banner "Sub-Command: ec2 server create [RUN LIST...] (options)"
banner "knife ec2 server create [RUN LIST...] (options)"

option :flavor,
:short => "-f FLAVOR",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/ec2_server_delete.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class Ec2ServerDelete < Knife

banner "Sub-Command: ec2 server delete SERVER [SERVER] (options)"
banner "knife ec2 server delete SERVER [SERVER] (options)"

option :aws_access_key_id,
:short => "-A ID",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/ec2_server_list.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class Ec2ServerList < Knife

banner "Sub-Command: ec2 server list [RUN LIST...] (options)"
banner "knife ec2 server list [RUN LIST...] (options)"

option :aws_access_key_id,
:short => "-A ID",
Expand Down
2 changes: 1 addition & 1 deletion chef/lib/chef/knife/index_rebuild.rb
Expand Up @@ -23,7 +23,7 @@ class Chef
class Knife
class IndexRebuild < Knife

banner "Sub-Command: index rebuild (options)"
banner "knife index rebuild (options)"
option :yes,
:short => "-y",
:long => "--yes",
Expand Down

0 comments on commit 645622c

Please sign in to comment.