Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 283decf747 | |||
| 293932534d | |||
| b3e5c1edcb |
@@ -14,8 +14,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Setup Go installation
|
- name: Setup Go installation
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
release:
|
|
||||||
types: [published]
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run:
|
run:
|
||||||
@@ -15,8 +13,6 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Setup Go installation
|
- name: Setup Go installation
|
||||||
uses: actions/setup-go@v5
|
uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
|
|||||||
21
main.go
21
main.go
@@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"yves-biener.de/wish-serve/internal/serve"
|
"yves-biener.de/wish-serve/internal/serve"
|
||||||
@@ -30,9 +31,29 @@ func loadConfig() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Overwrite (default) configuration value for the application to serve with
|
||||||
|
// given command line arguments.
|
||||||
|
//
|
||||||
|
// NOTE: This will also overwrite the configuration for the `app` entry from the
|
||||||
|
// configuration file.
|
||||||
|
func overwriteServeCommand() {
|
||||||
|
if len(os.Args) >= 2 {
|
||||||
|
name := os.Args[1]
|
||||||
|
viper.Set("app.name", name)
|
||||||
|
if len(os.Args) >= 3 {
|
||||||
|
args := os.Args[2:]
|
||||||
|
viper.Set("app.args", args)
|
||||||
|
} else {
|
||||||
|
// no arguments provided -> clear app arguments
|
||||||
|
viper.Set("app.args", []string{})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
createDefaultConfig()
|
createDefaultConfig()
|
||||||
loadConfig()
|
loadConfig()
|
||||||
|
overwriteServeCommand()
|
||||||
|
|
||||||
serve.Serve(
|
serve.Serve(
|
||||||
viper.GetString("host"),
|
viper.GetString("host"),
|
||||||
|
|||||||
Reference in New Issue
Block a user