Skip to content

Instantly share code, notes, and snippets.

/utter_shit.rb Secret

Created September 21, 2016 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5a7a23ee477a16ca31144caf8d023dda to your computer and use it in GitHub Desktop.
Save anonymous/5a7a23ee477a16ca31144caf8d023dda to your computer and use it in GitHub Desktop.
ATTRS = [:credentials_path, :bucket_name, :s3]
attr_reader(*ATTRS)
def initialize(credentials_path:, bucket_name:)
@credentials_path = credentials_path
@bucket_name = bucket_name
@prompt = TTY::Prompt.new
@s3 = S3.new(bucket_name: bucket_name)
parse_args
end
def parse_args
arg = ARGV[0].downcase
case arg
when '-i', '--interactive'
menu
when '-h', '--help'
# show help doc
else
delegate!(arg)
end
end
def menu
@prompt.select('Select an option') do |p|
p.choice '[Push] an object, creating a new version'
# ... etc
end
end
#######
private
#######
def delegate!(arg)
available_methods = (self.public_methods(false) - ATTRS)
if available_methods.include?(arg.to_sym)
send(arg)
else
raise ArgumentError, "No matching method for #{arg}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment