mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
27f57b2bbe
There should be no reason to use gopkg.in versioned imports now that we're using go modules. I think, IANAE. gopkg.in kind of gets in the way of modules, as it only pulls over tagged releases from github.com -- this then means that you need to use go modules 'replace' syntax in the go.mod to use a non-versioned commit or branch. This is feasible, but kind of ugly. go modules defaults to pulling the latest version, so the default behavior is the same as when pulling go-jira.v1 from gopkg.in.
47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package jiracmd
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/coryb/figtree"
|
|
"github.com/coryb/oreo"
|
|
jira "github.com/go-jira/jira"
|
|
"github.com/go-jira/jira/jiracli"
|
|
kingpin "gopkg.in/alecthomas/kingpin.v2"
|
|
)
|
|
|
|
type AttachRemoveOptions struct {
|
|
AttachmentID string `yaml:"attachment-id,omitempty" json:"attachment-id,omitempty"`
|
|
}
|
|
|
|
func CmdAttachRemoveRegistry() *jiracli.CommandRegistryEntry {
|
|
opts := AttachRemoveOptions{}
|
|
|
|
return &jiracli.CommandRegistryEntry{
|
|
"Delete attachment",
|
|
func(fig *figtree.FigTree, cmd *kingpin.CmdClause) error {
|
|
jiracli.LoadConfigs(cmd, fig, &opts)
|
|
return CmdAttachRemoveUsage(cmd, &opts)
|
|
},
|
|
func(o *oreo.Client, globals *jiracli.GlobalOptions) error {
|
|
return CmdAttachRemove(o, globals, &opts)
|
|
},
|
|
}
|
|
}
|
|
|
|
func CmdAttachRemoveUsage(cmd *kingpin.CmdClause, opts *AttachRemoveOptions) error {
|
|
cmd.Arg("ATTACHMENT-ID", "Attachment id to fetch").StringVar(&opts.AttachmentID)
|
|
return nil
|
|
}
|
|
|
|
func CmdAttachRemove(o *oreo.Client, globals *jiracli.GlobalOptions, opts *AttachRemoveOptions) error {
|
|
if err := jira.RemoveAttachment(o, globals.Endpoint.Value, opts.AttachmentID); err != nil {
|
|
return err
|
|
}
|
|
|
|
if !globals.Quiet.Value {
|
|
fmt.Printf("OK Deleted Attachment %s\n", opts.AttachmentID)
|
|
}
|
|
return nil
|
|
}
|