✨ Adds changing name and exiting
This commit is contained in:
parent
9547c72f5a
commit
473ea2ba74
@ -40,8 +40,8 @@ func load() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeReq(method string, url string, body io.Reader) error {
|
func makeReq(method string, url string) error {
|
||||||
req, err := http.NewRequest(method, url, body)
|
req, err := http.NewRequest(method, url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ func main() {
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "id",
|
Name: "id",
|
||||||
Usage: "optional id of a client to fetch",
|
Usage: "optional id of the client to fetch",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: clients,
|
Action: clients,
|
||||||
@ -95,7 +95,7 @@ func main() {
|
|||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "id",
|
Name: "id",
|
||||||
Usage: "optional id of a client to log",
|
Usage: "optional id of the client to log",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&cli.StringFlag{
|
||||||
Name: "date",
|
Name: "date",
|
||||||
@ -112,6 +112,35 @@ func main() {
|
|||||||
},
|
},
|
||||||
Action: logs,
|
Action: logs,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "name",
|
||||||
|
Usage: "rename a client",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "id",
|
||||||
|
Usage: "id of the client",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "new",
|
||||||
|
Usage: "new name of the client",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: name,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: "exit",
|
||||||
|
Usage: "request a client to disconnect",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "id",
|
||||||
|
Usage: "id of the client",
|
||||||
|
Required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: exit,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +164,7 @@ func clients(ctx context.Context, cmd *cli.Command) error {
|
|||||||
url = fmt.Sprintf("%s/admin/clients", server)
|
url = fmt.Sprintf("%s/admin/clients", server)
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeReq(http.MethodGet, url, nil)
|
return makeReq(http.MethodGet, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
func logs(ctx context.Context, cmd *cli.Command) error {
|
func logs(ctx context.Context, cmd *cli.Command) error {
|
||||||
@ -170,5 +199,28 @@ func logs(ctx context.Context, cmd *cli.Command) error {
|
|||||||
url = fmt.Sprintf("%s/admin/logs", server)
|
url = fmt.Sprintf("%s/admin/logs", server)
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeReq(http.MethodGet, url, nil)
|
return makeReq(http.MethodGet, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
func name(ctx context.Context, cmd *cli.Command) error {
|
||||||
|
err := load()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
id := cmd.String("id")
|
||||||
|
name := cmd.String("new")
|
||||||
|
url := fmt.Sprintf("%s/admin/name/%s?name=%s", server, id, name)
|
||||||
|
return makeReq(http.MethodPost, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
func exit(ctx context.Context, cmd *cli.Command) error {
|
||||||
|
err := load()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
id := cmd.String("id")
|
||||||
|
url := fmt.Sprintf("%s/admin/exit/%s", server, id)
|
||||||
|
return makeReq(http.MethodPost, url)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user