Method: Pasu::Runner#initialize
- Defined in:
- lib/pasu/runner.rb
#initialize ⇒ Runner
Returns a new instance of Runner.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pasu/runner.rb', line 3 def initialize OptionParser.new do |p| p. = 'Usage: pasu [options]' p.separator '' p.separator 'Options:' p.on('-v', '--version', 'Print version.') do puts "Pasu #{VERSION} (https://github.com/tbuehlmann/pasu)" exit end p.on('-d', '--directory DIRECTORY', 'Set the base directory for listing files. (Default: pwd)') do |dir| directory = Pathname.new(dir). if directory.directory? [:directory] = directory else puts "Couldn't find directory #{dir}" exit 1 end end p.on('--no-recursion', "Don't recursively list directories. (Default: false)") do [:recursive] = false end p.on('--no-dotfiles', "Don't list dotfiles. (Default: false)") do [:dotfiles] = false end p.on('-u', '--upload', 'Allow uploading of files. (Default: false)') do [:upload] = true end p.on('--basic-auth USER:PW', 'Only allowing requests with valid user/pw combination provided. (Default: None)') do |access| username, password = access.split(':') [:basic_auth] ||= {} [:basic_auth][username] = password end p.on('-b', '--bind HOST', 'Bind the server to the given host. (Default: 0.0.0.0)') do |host| [:host] = host end p.on('-p', '--port PORT', 'Bind the server to the given port. (Default: 8080)') do |port| [:port] = Integer(port) end p.on('-s', '--server RACK_HANDLER', 'Use your own rack handler. (Default: Puma)') do |handler| [:handler] = handler end p.on_tail('-h', '--help', 'Show this message.') do puts p exit end end.parse! end |