Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions icommand/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ var CmdConsole = cli.Command{
shell.AddCmd(policy(shell, ctx))
shell.AddCmd(role(shell, ctx))
shell.AddCmd(schedule(shell, ctx))
shell.AddCmd(users(shell, ctx))
shell.AddCmd(logger(shell, ctx))
shell.AddCmd(logout(shell, ctx))

// run shell
shell.Run()
Expand Down
19 changes: 18 additions & 1 deletion icommand/login.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package icommand

import "github.com/abiosoft/ishell"
import (
"github.com/abiosoft/ishell"
"github.com/ernestio/ernest-cli/command"
h "github.com/ernestio/ernest-cli/helper"
"github.com/urfave/cli"
)

func loginICmd(shell *ishell.Shell) func(c *ishell.Context) {
return func(c *ishell.Context) {
Expand All @@ -18,3 +23,15 @@ func loginICmd(shell *ishell.Shell) func(c *ishell.Context) {
updatePrompt(shell)
}
}

func logout(shell *ishell.Shell, ctx *cli.Context) *ishell.Cmd {
return &ishell.Cmd{
Name: "logout",
Help: h.T("logout.description"),
Func: func(c *ishell.Context) {
var args []string
var flags map[string]string
command.Logout.Run(getContext(ctx, args, flags))
},
}
}
58 changes: 58 additions & 0 deletions icommand/preferences.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package icommand

import (
"github.com/abiosoft/ishell"
"github.com/ernestio/ernest-cli/command"
h "github.com/ernestio/ernest-cli/helper"
"github.com/urfave/cli"
)

func logger(shell *ishell.Shell, ctx *cli.Context) *ishell.Cmd {
cmd := &ishell.Cmd{
Name: "logger",
Help: "Logger management",
}

cmd.AddCmd(&ishell.Cmd{
Name: "list",
Help: h.T("logger.list.description"),
Func: func(c *ishell.Context) {
var args []string
var flags map[string]string
command.ListLoggers.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "add",
Help: h.T("logger.set.description"),
Func: func(c *ishell.Context) {
args := mapArgs(c, map[string]input{
"name": input{out: "Logger name : "},
})
flags := mapFlags(c, map[string]input{
"logfile": input{out: "Log File : "},
"hostname": input{out: "Hostname : "},
"port": input{out: "Port : "},
"timeout": input{out: "Timeout : "},
"token": input{out: "Token : "},
"env": input{out: "Environment : "},
})
command.SetLogger.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "delete",
Help: h.T("logger.del.description"),
Func: func(c *ishell.Context) {
var flags map[string]string
args := mapArgs(c, map[string]input{
"name": input{out: "Notification name : "},
})
command.DelLogger.Run(getContext(ctx, args, flags))
},
})

return cmd
}
140 changes: 140 additions & 0 deletions icommand/user.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package icommand

import (
"github.com/abiosoft/ishell"
"github.com/ernestio/ernest-cli/command"
h "github.com/ernestio/ernest-cli/helper"
"github.com/urfave/cli"
)

func users(shell *ishell.Shell, ctx *cli.Context) *ishell.Cmd {
cmd := &ishell.Cmd{
Name: "user",
Help: "Users management",
}

cmd.AddCmd(&ishell.Cmd{
Name: "list",
Help: h.T("user.list.description"),
Func: func(c *ishell.Context) {
var args []string
var flags map[string]string
command.ListUsers.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "create",
Help: h.T("user.create.description"),
Func: func(c *ishell.Context) {
var args []string
flags := mapFlags(c, map[string]input{
"email": input{out: "Email : "},
})
args = mapArgs(c, map[string]input{
"username": input{out: "Username : "},
"pasword": input{out: "Password : "},
})
command.CreateUser.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "password",
Help: h.T("user.password.description"),
Func: func(c *ishell.Context) {
var args []string
flags := mapFlags(c, map[string]input{
"user": input{out: "Username : "},
"password": input{out: "Password : "},
})
command.DeletePolicy.Run(getContext(ctx, args, flags))

command.PasswordUser.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "disable",
Help: h.T("user.disable.description"),
Func: func(c *ishell.Context) {
var flags map[string]string
args := mapArgs(c, map[string]input{
"user": input{out: "Username : "},
})
command.UpdateNotification.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "info",
Help: h.T("user.info.description"),
Func: func(c *ishell.Context) {
var args []string
var flags map[string]string
command.InfoUser.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "add-admin",
Help: h.T("user.admin.add.description"),
Func: func(c *ishell.Context) {
var flags map[string]string
args := mapArgs(c, map[string]input{
"user": input{out: "Username : "},
})
command.AddAdminUser.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "rm-admin",
Help: h.T("user.admin.rm.description"),
Func: func(c *ishell.Context) {
var flags map[string]string
args := mapArgs(c, map[string]input{
"user": input{out: "Username : "},
})
command.RmAdminUser.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "enable-mfa",
Help: h.T("user.enable-mfa.description"),
Func: func(c *ishell.Context) {
var args []string
flags := mapFlags(c, map[string]input{
"user-name": input{out: "Username : "},
})
command.EnableMFA.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "disable-mfa",
Help: h.T("user.disable-mfa.description"),
Func: func(c *ishell.Context) {
var args []string
flags := mapFlags(c, map[string]input{
"user-name": input{out: "Username : "},
})
command.DisableMFA.Run(getContext(ctx, args, flags))
},
})

cmd.AddCmd(&ishell.Cmd{
Name: "reset-mfa",
Help: h.T("user.reset-mfa.description"),
Func: func(c *ishell.Context) {
var args []string
flags := mapFlags(c, map[string]input{
"user-name": input{out: "Username : "},
})
command.ResetMFA.Run(getContext(ctx, args, flags))
},
})

return cmd
}