summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJesse Wolfe <jes5199@gmail.com>2010-04-13 14:53:44 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit748aed9a4fe70cc2ecc0c782b694114356d9eb25 (patch)
tree749b66092e2d5dfea3a6bcf442c7a9e3cbd91d69 /lib
parenteafde5cacaac79da79d9d1415618801fcc37edcc (diff)
downloadpuppet-748aed9a4fe70cc2ecc0c782b694114356d9eb25.tar.gz
puppet-748aed9a4fe70cc2ecc0c782b694114356d9eb25.tar.xz
puppet-748aed9a4fe70cc2ecc0c782b694114356d9eb25.zip
Fix #3552 single executable should display usage
Added some tests to make the single executable command behavior explicit. Added logic to display the usage message if we're on a tty and no arguments are passed. Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/util/command_line.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
new file mode 100644
index 000000000..59454364c
--- /dev/null
+++ b/lib/puppet/util/command_line.rb
@@ -0,0 +1,15 @@
+module Puppet
+ module Util
+ module CommandLine
+ def self.shift_subcommand_from_argv( argv = ARGV, stdin = STDIN )
+ if ! argv.first
+ "main" unless stdin.tty? # ttys get usage info
+ elsif argv.first =~ /^-|\.pp$|\.rb$/
+ "main"
+ else
+ argv.shift
+ end
+ end
+ end
+ end
+end