2014-08-02 22:27:17 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2014-08-09 23:39:23 +02:00
|
|
|
"fmt"
|
2014-08-02 22:27:17 +02:00
|
|
|
"os"
|
|
|
|
|
|
2014-11-12 20:54:50 +01:00
|
|
|
"github.com/asciinema/asciinema-cli/api"
|
2014-08-02 22:27:17 +02:00
|
|
|
"github.com/asciinema/asciinema-cli/cli"
|
|
|
|
|
"github.com/asciinema/asciinema-cli/commands"
|
|
|
|
|
"github.com/asciinema/asciinema-cli/util"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
2015-02-02 19:07:52 +01:00
|
|
|
if !util.IsUtf8Locale() {
|
|
|
|
|
fmt.Println("asciinema needs a UTF-8 native locale to run. Check the output of `locale` command.")
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-12 20:58:14 +01:00
|
|
|
cfg, err := util.LoadConfig()
|
2014-11-12 20:54:50 +01:00
|
|
|
if err != nil {
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
os.Exit(1)
|
|
|
|
|
}
|
2014-08-09 23:39:23 +02:00
|
|
|
|
2014-11-15 13:33:20 +01:00
|
|
|
api := api.New(cfg.API.URL, cfg.API.Token, Version)
|
2014-09-07 11:59:13 +02:00
|
|
|
|
2014-11-12 20:54:50 +01:00
|
|
|
cli := &cli.CLI{
|
|
|
|
|
Commands: map[string]cli.Command{
|
|
|
|
|
"rec": commands.NewRecordCommand(api, cfg),
|
2015-02-24 16:22:31 +01:00
|
|
|
"play": commands.NewPlayCommand(),
|
2015-02-24 16:27:24 +01:00
|
|
|
"upload": commands.NewUploadCommand(api),
|
2014-11-12 20:54:50 +01:00
|
|
|
"auth": commands.NewAuthCommand(cfg),
|
|
|
|
|
"version": commands.NewVersionCommand(Version, GitCommit),
|
|
|
|
|
},
|
|
|
|
|
HelpFunc: help,
|
2014-09-07 11:59:13 +02:00
|
|
|
}
|
|
|
|
|
|
2014-11-12 20:54:50 +01:00
|
|
|
os.Exit(cli.Run(os.Args[1:]))
|
2014-08-09 23:39:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func help() {
|
2014-12-17 11:40:17 +01:00
|
|
|
fmt.Println(`usage: asciinema [-h] [-v] <command> [command-options]
|
2014-08-09 23:39:23 +02:00
|
|
|
|
2014-12-15 18:05:28 +01:00
|
|
|
Record and share your terminal sessions, the right way.
|
2014-08-09 23:39:23 +02:00
|
|
|
|
|
|
|
|
Commands:
|
2015-02-24 17:51:40 +01:00
|
|
|
rec [filename] Record terminal session
|
|
|
|
|
play <filename> Replay terminal session
|
|
|
|
|
upload <filename> Upload locally saved terminal session
|
|
|
|
|
auth Assign local API token to asciinema.org account
|
2014-08-09 23:39:23 +02:00
|
|
|
|
2014-12-17 11:40:17 +01:00
|
|
|
Options:
|
|
|
|
|
-h, --help Display help message
|
|
|
|
|
-v, --version Display version information
|
|
|
|
|
|
|
|
|
|
Run "asciinema <command> -h" to see the options available for the given command.`)
|
2014-08-09 23:39:23 +02:00
|
|
|
}
|