Skip to content

Commit 45319ac

Browse files
committed
support ssh-arg in config file
1 parent d01b681 commit 45319ac

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/client/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ var CliClientOpenCommand = cli.Command{
9898
},
9999

100100
&cli.StringSliceFlag{
101-
Name: "ssh-arg",
102-
Usage: "Additional arguments to pass to the SSH command",
103-
Sources: cli.EnvVars("NVRH_CLIENT_SSH_ARG"),
101+
Name: "ssh-arg",
102+
Usage: "Additional arguments to pass to the SSH command [$NVRH_CLIENT_SSH_ARG]",
103+
// Sources: cli.EnvVars("NVRH_CLIENT_SSH_ARG"),
104104
},
105105

106106
&cli.BoolFlag{
@@ -407,9 +407,9 @@ var CliClientReconnectCommand = cli.Command{
407407
},
408408

409409
&cli.StringSliceFlag{
410-
Name: "ssh-arg",
411-
Usage: "Additional arguments to pass to the SSH command",
412-
Sources: cli.EnvVars("NVRH_CLIENT_SSH_ARG"),
410+
Name: "ssh-arg",
411+
Usage: "Additional arguments to pass to the SSH command [$NVRH_CLIENT_SSH_ARG]",
412+
// Sources: cli.EnvVars("NVRH_CLIENT_SSH_ARG"),
413413
},
414414
},
415415

src/nvrh_config/main.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import (
1111
)
1212

1313
type NvrhConfigServer struct {
14-
NvimCmd []string `yaml:"nvim-cmd"`
14+
NvimCmd []string `yaml:"nvim-cmd,omitempty"`
1515
UsePorts *bool `yaml:"use-ports,omitempty"`
16+
SshArg []string `yaml:"ssh-arg,omitempty"`
1617
}
1718

1819
type NvrhConfig struct {
@@ -50,6 +51,7 @@ func LoadConfig(path string) (*NvrhConfig, error) {
5051
var envIndex = map[string][]string{
5152
"nvim-cmd": {"NVRH_CLIENT_NVIM_CMD"},
5253
"use-ports": {"NVRH_CLIENT_USE_PORTS"},
54+
"ssh-arg": {"NVRH_CLIENT_SSH_ARG"},
5355
}
5456

5557
func ApplyPrecedence(c *cli.Command, sc NvrhConfigServer) error {
@@ -68,6 +70,14 @@ func ApplyPrecedence(c *cli.Command, sc NvrhConfigServer) error {
6870
}
6971
}
7072

73+
if !c.IsSet("ssh-arg") && len(sc.SshArg) > 0 {
74+
for _, v := range sc.SshArg {
75+
if err := c.Set("ssh-arg", v); err != nil {
76+
return err
77+
}
78+
}
79+
}
80+
7181
// Fall back to environment variables if still not set.
7282
for name, keys := range envIndex {
7383
if c.IsSet(name) {

0 commit comments

Comments
 (0)