This repository was archived by the owner on Jan 16, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathlist.go
57 lines (49 loc) · 1.31 KB
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"os"
"github.com/ParsePlatform/parse-cli/parsecli"
"github.com/facebookgo/stackerr"
"github.com/spf13/cobra"
)
const (
applications = "applications"
)
type listCmd struct{}
func (l *listCmd) printListOfApps(e *parsecli.Env) error {
config, err := parsecli.ConfigFromDir(e.Root)
if err != nil {
if os.IsNotExist(err) {
// print nothing if we are not in a parse app directory
return nil
}
return stackerr.Wrap(err)
}
config.PrettyPrintApps(e)
fmt.Fprintln(e.Out, "")
return nil
}
func (l *listCmd) run(e *parsecli.Env, args []string) error {
l.printListOfApps(e)
var apps parsecli.Apps
if err := apps.Login.AuthUser(e, false); err != nil {
return err
}
var appName string
if len(args) > 0 {
appName = args[0]
}
return apps.ShowApps(e, appName)
}
func NewListCmd(e *parsecli.Env) *cobra.Command {
l := listCmd{}
return &cobra.Command{
Use: "list [app]",
Short: "Lists properties of given Parse app and Parse apps associated with given project",
Long: `Lists Parse apps and aliases added to the current Cloud Code directory
when executed inside the directory.
Additionally, it prints the list of Parse apps associated with current Parse account.
If an optional app name is provided, it prints all the keys for that app.`,
Run: parsecli.RunWithArgs(e, l.run),
}
}