Skip to content

Commit

Permalink
minor: rename cmd struct fields
Browse files Browse the repository at this point in the history
  • Loading branch information
kkga committed Dec 19, 2021
1 parent 1832f49 commit 2390272
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 36 deletions.
10 changes: 5 additions & 5 deletions cmd/attach.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (

func NewAttachCmd() *AttachCmd {
c := &AttachCmd{Cmd: Cmd{
fs: flag.NewFlagSet("attach", flag.ExitOnError),
alias: []string{"a"},
shortDesc: "Attach to Kakoune session with a new client.",
usageLine: "[options] [file] [+<line>[:<col]]",
sessionReq: true,
fs: flag.NewFlagSet("attach", flag.ExitOnError),
aliases: []string{"a"},
shortDesc: "Attach to Kakoune session with a new client.",
usageLine: "[options] [file] [+<line>[:<col]]",
sessionRequired: true,
}}
c.fs.StringVar(&c.session, "s", "", "session")
return c
Expand Down
12 changes: 6 additions & 6 deletions cmd/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (

func NewCatCmd() *CatCmd {
c := &CatCmd{Cmd: Cmd{
fs: flag.NewFlagSet("cat", flag.ExitOnError),
alias: []string{""},
shortDesc: "Print contents of a buffer to stdout.",
usageLine: "[options]",
sessionReq: true,
clientReq: true,
fs: flag.NewFlagSet("cat", flag.ExitOnError),
aliases: []string{""},
shortDesc: "Print contents of a buffer to stdout.",
usageLine: "[options]",
sessionRequired: true,
clientRequired: true,
}}
c.fs.StringVar(&c.session, "s", "", "session")
c.fs.StringVar(&c.client, "c", "", "client")
Expand Down
16 changes: 8 additions & 8 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ type Runner interface {

type Cmd struct {
fs *flag.FlagSet
alias []string
aliases []string
shortDesc string
usageLine string

session string
client string
buffer string

sessionReq bool
clientReq bool
bufferReq bool
sessionRequired bool
clientRequired bool
bufferRequired bool

kctx *kak.Context

Expand All @@ -39,7 +39,7 @@ type Cmd struct {

func (c *Cmd) Run() error { return nil }
func (c *Cmd) Name() string { return c.fs.Name() }
func (c *Cmd) Alias() []string { return c.alias }
func (c *Cmd) Alias() []string { return c.aliases }

var (
errNoSession = errors.New("no session in context")
Expand Down Expand Up @@ -77,13 +77,13 @@ func (c *Cmd) Init(args []string) error {
Buffer: kak.Buffer{Name: c.buffer},
}

if c.sessionReq && c.kctx.Session.Name == "" {
if c.sessionRequired && c.kctx.Session.Name == "" {
return errNoSession
}
if c.clientReq && c.kctx.Client.Name == "" {
if c.clientRequired && c.kctx.Client.Name == "" {
return errNoClient
}
if c.bufferReq && c.kctx.Buffer.Name == "" {
if c.bufferRequired && c.kctx.Buffer.Name == "" {
return errNoBuffer
}

Expand Down
3 changes: 1 addition & 2 deletions cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import (
func NewEditCmd() *EditCmd {
c := &EditCmd{Cmd: Cmd{
fs: flag.NewFlagSet("edit", flag.ExitOnError),
alias: []string{"e"},
aliases: []string{"e"},
shortDesc: "Edit file. In session and client, if set.",
usageLine: "[options] [file] [+<line>[:<col>]]",
}}
// TODO add flag that allows creating new files (removes -existing)
c.fs.StringVar(&c.session, "s", "", "session")
c.fs.StringVar(&c.client, "c", "", "client")
return c
Expand Down
10 changes: 5 additions & 5 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (

func NewEnvCmd() *EnvCmd {
c := &EnvCmd{Cmd: Cmd{
fs: flag.NewFlagSet("env", flag.ExitOnError),
alias: []string{""},
shortDesc: "Print current Kakoune context set by environment to stdout.",
usageLine: "[options]",
sessionReq: true,
fs: flag.NewFlagSet("env", flag.ExitOnError),
aliases: []string{""},
shortDesc: "Print current Kakoune context set by environment to stdout.",
usageLine: "[options]",
sessionRequired: true,
}}
c.fs.BoolVar(&c.json, "json", false, "json output")
return c
Expand Down
10 changes: 5 additions & 5 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (

func NewGetCmd() *GetCmd {
c := &GetCmd{Cmd: Cmd{
fs: flag.NewFlagSet("get", flag.ExitOnError),
alias: []string{""},
shortDesc: "Get states from Kakoune context.",
usageLine: "[options] (<%val{..}> | <%opt{..}> | <%reg{..}> | <%sh{..}>)",
sessionReq: true,
fs: flag.NewFlagSet("get", flag.ExitOnError),
aliases: []string{""},
shortDesc: "Get states from Kakoune context.",
usageLine: "[options] (<%val{..}> | <%opt{..}> | <%reg{..}> | <%sh{..}>)",
sessionRequired: true,
}}
c.fs.StringVar(&c.session, "s", "", "session")
c.fs.StringVar(&c.client, "c", "", "client")
Expand Down
2 changes: 1 addition & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var initKak string
func NewInitCmd() *InitCmd {
c := &InitCmd{Cmd: Cmd{
fs: flag.NewFlagSet("init", flag.ExitOnError),
alias: []string{""},
aliases: []string{""},
shortDesc: "Print Kakoune command definitions to stdout.",
usageLine: "",
}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func NewKillCmd() *KillCmd {
c := &KillCmd{Cmd: Cmd{
fs: flag.NewFlagSet("kill", flag.ExitOnError),
alias: []string{""},
aliases: []string{""},
shortDesc: "Terminate Kakoune session.",
usageLine: "[options]",
}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
func NewListCmd() *ListCmd {
c := &ListCmd{Cmd: Cmd{
fs: flag.NewFlagSet("list", flag.ExitOnError),
alias: []string{"ls", "l"},
aliases: []string{"ls", "l"},
shortDesc: "List Kakoune sessions and clients.",
usageLine: "[options]",
}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func NewNewCmd() *NewCmd {
c := &NewCmd{Cmd: Cmd{
fs: flag.NewFlagSet("new", flag.ExitOnError),
alias: []string{"n"},
aliases: []string{"n"},
shortDesc: "Start new headless Kakoune session.",
usageLine: "[<name>]",
}}
Expand Down
2 changes: 1 addition & 1 deletion cmd/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func NewSendCmd() *SendCmd {
c := &SendCmd{Cmd: Cmd{
fs: flag.NewFlagSet("send", flag.ExitOnError),
alias: []string{"s"},
aliases: []string{"s"},
shortDesc: "Send commands to Kakoune context.",
usageLine: "[options] <command>",
}}
Expand Down

0 comments on commit 2390272

Please sign in to comment.