Skip to content

Instantly share code, notes, and snippets.

View Poincare's full-sized avatar

Dhaivat Pandya Poincare

View GitHub Profile
ruby file-ops-v2.rb output --stderr filename
require 'thor'
class FileOp < Thor
desc 'output FILE_NAME', 'print out the contents of FILE_NAME'
option :stderr, :type => :boolean
def output(file_name)
#options[:stderr] is either true or false depending
#on whether or not --stderr was passed
contents = File.read(file_name)
Usage:
file_op_v1.rb output FILE_NAME
print out the contents of FILE_NAME
ruby file-op.rb help output
require 'thor'
class FileOp < Thor
desc 'output FILE_NAME', 'print out the contents of FILE_NAME'
def output(file_name)
puts File.read(file_name)
end
end
Commands:
first_steps.rb help [COMMAND] # Describe available commands or one specific command
first_steps.rb hi NAME # say hello to NAME
require 'thor'
class SayHi < Thor
desc "hi NAME", "say hello to NAME"
def hi(name)
puts "Hi #{name}!"
end
end
use Getopt::Long;
my $data = "file.dat";
my $length = 24;
my $verbose;
GetOptions("length=i" => \$length,
"file=s" => \$data,
"verbose" => \$verbose) or die("Error in command line arguments");
while (1)
{
static struct option long_options[] =
{
/* These options set a flag. */
{"verbose", no_argument, &verbose_flag, 1},
{"brief", no_argument, &verbose_flag, 0},
/* These options don't set a flag.
We distinguish them by their indices. */
{"add", no_argument, 0, 'a'},
git remote add dokku git@HOSTNAME:APPNAME
git push dokku master