package main import ( "time" s3browser "git.kapelle.org/niklas/s3browser/internal" types "git.kapelle.org/niklas/s3browser/internal/types" "github.com/alexflint/go-arg" ) type args struct { S3Endpoint string `arg:"--s3-endpoint,required,env:S3_ENDPOINT" help:"host[:port]" placeholder:"ENDPOINT"` S3AccessKey string `arg:"--s3-access-key,required,env:S3_ACCESS_KEY" placeholder:"ACCESS_KEY"` S3SecretKey string `arg:"--s3-secret-key,required,env:S3_SECRET_KEY" placeholder:"SECRET_KEY"` S3Bucket string `arg:"--s3-bucket,required,env:S3_BUCKET" placeholder:"BUCKET"` S3DisableSSL bool `arg:"--s3-disable-ssl,env:S3_DISABLE_SSL" default:"false"` Address string `arg:"--address,env:ADDRESS" default:":3000" help:"what address to listen on" placeholder:"ADDRESS"` CacheTTL int64 `arg:"--cache-ttl,env:CACHE_TTL" help:"Time in seconds" default:"30" placeholder:"TTL"` CacheCleanup int64 `arg:"--cache-cleanup,env:CACHE_CLEANUP" help:"Time in seconds" default:"60" placeholder:"CLEANUP"` Verbose bool `arg:"-v,--verbose,env:VERBOSE" help:"verbosity level" default:"false"` DBConnection string `arg:"--db,required,env:DB_CONNECTION" help:"DSN in format: https://github.com/go-sql-driver/mysql#dsn-data-source-name"` } func (args) Version() string { // TODO return "s3Browser 0.1" } func main() { var args args arg.MustParse(&args) s3browser.Start(types.AppConfig{ S3Endoint: args.S3Endpoint, S3SSL: !args.S3DisableSSL, S3AccessKey: args.S3AccessKey, S3SecretKey: args.S3SecretKey, S3Bucket: args.S3Bucket, DSN: args.DBConnection, CacheTTL: time.Duration(args.CacheTTL) * time.Second, CacheCleanup: time.Duration(args.CacheCleanup) * time.Second, Address: args.Address, LogDebug: args.Verbose, }) }