2015-06-08 02:36:07 +02:00
package main
import (
"log"
"os"
2015-06-12 23:34:49 +02:00
"path"
2015-06-08 02:36:07 +02:00
"github.com/codegangsta/cli"
)
// Logger is used to log errors; if nil, the default log.Logger is used.
var Logger * log . Logger
// logger is an helper function to retrieve the available logger
func logger ( ) * log . Logger {
if Logger == nil {
Logger = log . New ( os . Stderr , "" , log . LstdFlags )
}
return Logger
}
func main ( ) {
app := cli . NewApp ( )
app . Name = "lego"
app . Usage = "Let's encrypt client to go!"
2015-09-26 20:00:19 +02:00
app . Version = "0.0.2"
2015-06-08 02:36:07 +02:00
2015-06-12 23:34:49 +02:00
cwd , err := os . Getwd ( )
if err != nil {
logger ( ) . Fatal ( "Could not determine current working directory. Please pass --path." )
}
defaultPath := path . Join ( cwd , ".lego" )
2015-06-08 02:36:07 +02:00
app . Commands = [ ] cli . Command {
{
Name : "run" ,
2015-09-27 14:50:45 +02:00
Usage : "Register an account, then create and install a certificate" ,
2015-06-08 02:36:07 +02:00
Action : run ,
} ,
{
Name : "auth" ,
2015-09-27 14:50:45 +02:00
Usage : "Create a certificate - must already have an account" ,
2015-06-08 02:36:07 +02:00
Action : func ( c * cli . Context ) {
logger ( ) . Fatal ( "Not implemented" )
} ,
} ,
{
2015-09-27 14:50:45 +02:00
Name : "revoke" ,
Usage : "Revoke a certificate" ,
Action : revoke ,
2015-06-08 02:36:07 +02:00
} ,
}
app . Flags = [ ] cli . Flag {
cli . StringSliceFlag {
Name : "domains, d" ,
Usage : "Add domains to the process" ,
} ,
cli . StringFlag {
Name : "server, s" ,
2015-09-26 22:59:16 +02:00
Value : "https://acme-staging.api.letsencrypt.org/" ,
2015-06-08 02:36:07 +02:00
Usage : "CA hostname (and optionally :port). The server certificate must be trusted in order to avoid further modifications to the client." ,
} ,
cli . StringFlag {
Name : "email, m" ,
Usage : "Email used for registration and recovery contact." ,
} ,
cli . IntFlag {
Name : "rsa-key-size, B" ,
Value : 2048 ,
Usage : "Size of the RSA key." ,
} ,
cli . StringFlag {
2015-06-12 23:34:49 +02:00
Name : "path" ,
Usage : "Directory to use for storing the data" ,
Value : defaultPath ,
2015-06-08 02:36:07 +02:00
} ,
2015-06-13 00:16:49 +02:00
cli . StringFlag {
Name : "port" ,
Usage : "Challenges will use this port to listen on. Please make sure to forward port 443 to this port on your machine. Otherwise use setcap on the binary" ,
} ,
2015-10-18 01:57:46 +02:00
cli . BoolFlag {
Name : "devMode" ,
Usage : "If set to true, all client side challenge pre-tests are skipped." ,
} ,
2015-06-08 02:36:07 +02:00
}
app . Run ( os . Args )
}