diff options
author | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-11-05 19:21:19 +0530 |
---|---|---|
committer | Vivek Singh <vivek.singh@msystechnologies.com> | 2019-11-05 19:21:19 +0530 |
commit | c29b8da2b0353bb5d6e499b5d7cc79c0fadab9b3 (patch) | |
tree | d61162809902543dc8d21c07c77387e7c48781d7 /lib/chef/knife | |
parent | 81d22f6e8cd95254a272d8b303f0b6427b3bc888 (diff) | |
download | chef-c29b8da2b0353bb5d6e499b5d7cc79c0fadab9b3.tar.gz |
Validate name argument for knife list
- Add required specs.
- Raise an error if no argument provided.
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/list.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb index e5e196ecea..03e8cf199c 100644 --- a/lib/chef/knife/list.rb +++ b/lib/chef/knife/list.rb @@ -62,10 +62,15 @@ class Chef attr_accessor :exit_code def run - patterns = name_args.length == 0 ? [""] : name_args + + if name_args.length == 0 + show_usage + ui.fatal("You must specify at least one argument. If you want to list everything in this directory, run \"knife list .\"") + exit 1 + end # Get the top-level matches - all_results = parallelize(pattern_args_from(patterns)) do |pattern| + all_results = parallelize(pattern_args_from(name_args)) do |pattern| pattern_results = Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern).to_a if pattern_results.first && !pattern_results.first.exists? && pattern.exact_path |