2021-03-31 16:56:34 +01:00
|
|
|
// Copyright (C) 2021 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/zeebo/clingy"
|
|
|
|
|
2021-05-26 21:19:29 +01:00
|
|
|
_ "storj.io/private/process"
|
|
|
|
"storj.io/storj/cmd/uplinkng/ulext"
|
|
|
|
)
|
2021-03-31 16:56:34 +01:00
|
|
|
|
|
|
|
func main() {
|
2021-05-26 21:19:29 +01:00
|
|
|
ex := newExternal()
|
2021-05-05 22:53:08 +01:00
|
|
|
ok, err := clingy.Environment{
|
2021-05-26 21:19:29 +01:00
|
|
|
Name: "uplink",
|
|
|
|
Args: os.Args[1:],
|
|
|
|
Dynamic: ex.Dynamic,
|
|
|
|
Wrap: ex.Wrap,
|
2021-05-25 00:11:50 +01:00
|
|
|
}.Run(context.Background(), func(cmds clingy.Commands) {
|
2021-05-26 21:19:29 +01:00
|
|
|
ex.Setup(cmds) // setup ex first so that stdlib flags can consult config
|
2021-05-25 00:11:50 +01:00
|
|
|
newStdlibFlags(flag.CommandLine).Setup(cmds)
|
2021-05-26 21:19:29 +01:00
|
|
|
commands(cmds, ex)
|
2021-03-31 16:56:34 +01:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintf(os.Stderr, "%+v\n", err)
|
|
|
|
}
|
|
|
|
if !ok || err != nil {
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
2021-05-05 22:53:08 +01:00
|
|
|
|
2021-05-26 21:19:29 +01:00
|
|
|
func commands(cmds clingy.Commands, ex ulext.External) {
|
2021-05-25 00:11:50 +01:00
|
|
|
cmds.Group("access", "Access related commands", func() {
|
2021-05-26 21:19:29 +01:00
|
|
|
cmds.New("save", "Save an existing access", newCmdAccessSave(ex))
|
|
|
|
cmds.New("create", "Create an access from a setup token", newCmdAccessCreate(ex))
|
|
|
|
cmds.New("delete", "Delete an access from local store", newCmdAccessDelete(ex))
|
2021-06-22 23:41:22 +01:00
|
|
|
cmds.New("restrict", "Restrict an access", newCmdAccessRestrict(ex))
|
2021-05-26 21:19:29 +01:00
|
|
|
cmds.New("list", "List saved accesses", newCmdAccessList(ex))
|
|
|
|
cmds.New("use", "Set default access to use", newCmdAccessUse(ex))
|
|
|
|
cmds.New("revoke", "Revoke an access", newCmdAccessRevoke(ex))
|
2021-10-25 18:30:12 +01:00
|
|
|
cmds.New("inspect", "Inspect allows you to explode a serialized access into its constituent parts", newCmdAccessInspect(ex))
|
2021-11-25 12:53:52 +00:00
|
|
|
cmds.New("register", "Register an access grant for use with a hosted S3 compatible gateway and linksharing", newCmdAccessRegister(ex))
|
2021-05-05 22:53:08 +01:00
|
|
|
})
|
2021-05-26 21:19:29 +01:00
|
|
|
cmds.New("share", "Shares restricted accesses to objects", newCmdShare(ex))
|
|
|
|
cmds.New("mb", "Create a new bucket", newCmdMb(ex))
|
|
|
|
cmds.New("rb", "Remove a bucket bucket", newCmdRb(ex))
|
2021-10-20 17:25:20 +01:00
|
|
|
cmds.New("cp", "Copies files or objects into or out of storj", newCmdCp(ex))
|
2021-10-05 17:48:13 +01:00
|
|
|
cmds.New("mv", "Moves files or objects", newCmdMv(ex))
|
2021-05-26 21:19:29 +01:00
|
|
|
cmds.New("ls", "Lists buckets, prefixes, or objects", newCmdLs(ex))
|
|
|
|
cmds.New("rm", "Remove an object", newCmdRm(ex))
|
2021-05-25 00:11:50 +01:00
|
|
|
cmds.Group("meta", "Object metadata related commands", func() {
|
2021-05-26 21:19:29 +01:00
|
|
|
cmds.New("get", "Get an object's metadata", newCmdMetaGet(ex))
|
2021-05-05 22:53:08 +01:00
|
|
|
})
|
2021-05-26 21:19:29 +01:00
|
|
|
cmds.New("version", "Prints version information", newCmdVersion())
|
2021-05-05 22:53:08 +01:00
|
|
|
}
|