Skip to content

Commit

Permalink
Merge branch 'master' into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalcaliskan committed Jan 14, 2024
2 parents 7162fa3 + ee767cd commit 254f54a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 94 deletions.
38 changes: 0 additions & 38 deletions cmd/foo/foo.go

This file was deleted.

24 changes: 0 additions & 24 deletions cmd/foo/options/options.go

This file was deleted.

19 changes: 0 additions & 19 deletions cmd/foo/options/options_test.go

This file was deleted.

9 changes: 6 additions & 3 deletions cmd/root/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ var rootOptions = &RootOptions{}
type (
OptsKey struct{}
LoggerKey struct{}
DomainKey struct{}
DnsKey struct{}
)

// RootOptions contains frequent command line and application options.
type RootOptions struct {
// Key is the dummy option
Key string
Domain string
DnsServers string
}

// GetRootOptions returns the pointer of RootOptions
Expand All @@ -21,5 +23,6 @@ func GetRootOptions() *RootOptions {
}

func (opts *RootOptions) InitFlags(cmd *cobra.Command) {
cmd.PersistentFlags().StringVarP(&opts.Key, "key", "", "", "")
cmd.Flags().StringVarP(&opts.Domain, "domain", "", "", "domain to be used for split tunneling")
cmd.Flags().StringVarP(&opts.DnsServers, "dns-servers", "", "", "comma separated dns servers to be used for split tunneling")
}
14 changes: 4 additions & 10 deletions cmd/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"os"

"github.com/bilalcaliskan/split-the-tunnel/cmd/foo"
"github.com/bilalcaliskan/split-the-tunnel/cmd/root/options"

"github.com/bilalcaliskan/split-the-tunnel/internal/logging"
Expand All @@ -15,14 +14,11 @@ import (
var (
opts *options.RootOptions
ver = version.Get()
//bannerFilePath = "build/ci/banner.txt"
)

func init() {
opts = options.GetRootOptions()
opts.InitFlags(rootCmd)

rootCmd.AddCommand(foo.FooCmd)
}

// rootCmd represents the base command when called without any subcommands
Expand All @@ -32,15 +28,13 @@ var rootCmd = &cobra.Command{
Long: ``,
Version: ver.GitVersion,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
//if _, err := os.Stat("build/ci/banner.txt"); err == nil {
// bannerBytes, _ := os.ReadFile("build/ci/banner.txt")
// banner.Init(os.Stdout, true, false, strings.NewReader(string(bannerBytes)))
//}

logger := logging.GetLogger()
logger.Info().Str("appVersion", ver.GitVersion).Str("goVersion", ver.GoVersion).Str("goOS", ver.GoOs).
Str("goArch", ver.GoArch).Str("gitCommit", ver.GitCommit).Str("buildDate", ver.BuildDate).
Msg("golang-cli-template is started!")
Msg("split-the-tunnel is started!")

logger.Info().Msg(opts.Domain)
logger.Info().Msg(opts.DnsServers)

cmd.SetContext(context.WithValue(cmd.Context(), options.LoggerKey{}, logger))
cmd.SetContext(context.WithValue(cmd.Context(), options.OptsKey{}, opts))
Expand Down

0 comments on commit 254f54a

Please sign in to comment.