class Staticd::CLI
Public Class Methods
new()
click to toggle source
# File lib/staticd/cli.rb, line 7 def initialize @gli = GLIObject.new @gli.program_desc("Staticd HTTP and API server") @gli.version(Staticd::VERSION) @gli.on_error { |exception| raise exception } build_commands end
Public Instance Methods
run(*args)
click to toggle source
# File lib/staticd/cli.rb, line 15 def run(*args) @gli.run(*args) end
Private Instance Methods
build_command_server()
click to toggle source
# File lib/staticd/cli.rb, line 25 def build_command_server @gli.desc("Start the staticd API and HTTP services") @gli.command(:server) do |c| c.switch([:api], desc: "enable the API service", default_value: true) c.switch([:http], desc: "enable the HTTP service", default_value: true) c.flag( [:environment], desc: "application environment", default_value: :development ) c.flag( [:domain], desc: "base to generate per app sub-domain" ) c.flag( [:public_port], desc: "port used to generate application and endpoint url" ) c.flag([:access_id], desc: "HMAC auth access id for the API service") c.flag([:secret_key], desc: "HMAC auth secret key for the API service") c.flag([:database], desc: "URL for the database") c.flag([:datastore], desc: "URL for the datastore") c.flag( [:http_cache], desc: "directory path where HTTP resources are cached", default_value: "/var/cache/staticd" ) c.flag([:host], desc: "address to listen to", default_value: "0.0.0.0") c.flag([:port], desc: "port to listen to", default_value: 80) c.flag([:config], desc: "load a config file") c.action do |global_options, options,args| # Load configuration from command line options, environment variables # options and config file. Staticd::Config << options Staticd::Config.load_env Staticd::Config.load_file(options[:config]) if options[:config] # Initialize and start the Staticd app. app = Staticd::App.new(Staticd::Config) app.run end end end
build_commands()
click to toggle source
# File lib/staticd/cli.rb, line 21 def build_commands build_command_server end