Refactored main.go into cmd/jobsearch/main.go (in case separate commands are introduced later) which has required the options mechanism to change slightly as well as the logging.
This commit is contained in:
1 parent
de3ebf68c5
commit
6436253629
14 files changed
+273
-224
No files matched your search
@@ -17,7 +17,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
@@ -25,7 +24,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func commandGet() *cobra.Command {
|
||||
func commandGet(opts *cli.Options) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "get [config_key]",
|
||||
Args: cobra.ExactArgs(1),
|
||||
@@ -43,9 +42,9 @@ func commandGet() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
conf, ok := cli.ConfigFromContext(cmd.Context())
|
||||
if !ok {
|
||||
return errors.New("no configuration loaded")
|
||||
conf, err := opts.RunSetup(cmd, true, true)
|
||||
if err != nil {
|
||||
return fmt.Errorf("no configuration loaded (%w)", err)
|
||||
}
|
||||
|
||||
v, err := conf.ValueOf(args[0])
|
||||
@@ -57,9 +56,6 @@ func commandGet() *cobra.Command {
|
||||
|
||||
return nil
|
||||
},
|
||||
Annotations: map[string]string{
|
||||
"terminal_log": "1",
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
Reference in new issue
Block a user