Add delete
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2022-01-21 07:17:52 +01:00
parent ff8c6aca64
commit ed4a10c966
5 changed files with 101 additions and 0 deletions

View File

@@ -39,6 +39,22 @@ func ActionUpload(c *cli.Context) error {
return nil
}
func ActionDelete(c *cli.Context) error {
clnt := client.Client{
BaseURL: c.String("url"),
}
for _, arg := range c.Args().Slice() {
ctx, cancel := context.WithTimeout(c.Context, 5*time.Second)
defer cancel()
if err := clnt.Delete(ctx, arg); err != nil {
fmt.Printf("Error deleting file %s\n", arg)
fmt.Printf("%s\n", err)
}
fmt.Printf("Deleted %s\n", arg)
}
return nil
}
func ActionLogin(c *cli.Context) error {
username := c.Args().First()
if username == "" {

View File

@@ -37,6 +37,12 @@ func main() {
ArgsUsage: "FILE [FILE]...",
Action: actions.ActionUpload,
},
{
Name: "delete",
Usage: "Delete file(s)",
ArgsUsage: "FILE [FILE]...",
Action: actions.ActionDelete,
},
{
Name: "login",
Usage: "Login to gpaste server",