NewCmd returns a new login command
(ctx context.DnoteCtx)
| 38 | |
| 39 | // NewCmd returns a new login command |
| 40 | func NewCmd(ctx context.DnoteCtx) *cobra.Command { |
| 41 | cmd := &cobra.Command{ |
| 42 | Use: "login", |
| 43 | Short: "Login to dnote server", |
| 44 | Example: example, |
| 45 | RunE: newRun(ctx), |
| 46 | } |
| 47 | |
| 48 | f := cmd.Flags() |
| 49 | f.StringVarP(&usernameFlag, "username", "u", "", "email address for authentication") |
| 50 | f.StringVarP(&passwordFlag, "password", "p", "", "password for authentication") |
| 51 | f.StringVar(&apiEndpointFlag, "apiEndpoint", "", "API endpoint to connect to (defaults to value in config)") |
| 52 | |
| 53 | return cmd |
| 54 | } |
| 55 | |
| 56 | // Do dervies credentials on the client side and requests a session token from the server |
| 57 | func Do(ctx context.DnoteCtx, email, password string) error { |