Skip to content

Commit

Permalink
fix options overriding config
Browse files Browse the repository at this point in the history
  • Loading branch information
pomdtr committed Aug 29, 2024
1 parent c8a7ebe commit 8dc1188
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/open.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func NewCmdOpen() *cobra.Command {
}

apps, err := ListApps(k.String("domain"), utils.ExpandTilde(k.String("dir")))
if err != nil {
return fmt.Errorf("failed to list apps: %v", err)
}

for _, app := range apps {
if app.Dir != dir {
continue
Expand Down
2 changes: 0 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ var k = koanf.New(".")

func NewCmdRoot(version string) *cobra.Command {
defaultProvider := confmap.Provider(map[string]interface{}{
"host": "127.0.0.1",
"port": 7777,
"domain": "localhost",
"dir": "~/smallweb",
"env": map[string]string{
Expand Down
4 changes: 4 additions & 0 deletions cmd/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func NewCmdUp() *cobra.Command {
Aliases: []string{"serve"},
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if err := k.Load(posflag.Provider(cmd.Flags(), ".", k), nil); err != nil {
return fmt.Errorf("error loading config: %w", err)
}

port := k.Int("port")
if port == 0 && flags.tls {
port = 443
Expand Down

0 comments on commit 8dc1188

Please sign in to comment.