Skip to content

Commit f3fed50

Browse files
committed
refactor: cleanup serve command
1 parent 96f4f4d commit f3fed50

40 files changed

Lines changed: 29 additions & 700 deletions

example/config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,4 @@
4444
# - ONEKEYMAP_TELEMETRY_ENDPOINT -> telemetry.endpoint
4545
# - ONEKEYMAP_TELEMETRY_HEADERS -> telemetry.headers
4646
# - ONEKEYMAP_TELEMETRY_INSECURE -> telemetry.insecure
47-
# - ONEKEYMAP_SERVER_LISTEN -> server.listen
4847
# - ONEKEYMAP_EDITORS_VSCODE_KEYMAP_PATH -> editors.vscode.keymap_path

internal/cliconfig/config.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ type Config struct {
4545
OneKeyMap string `mapstructure:"onekeymap"`
4646
// Telemetry holds OpenTelemetry configuration.
4747
Telemetry TelemetryConfig `mapstructure:"telemetry"`
48-
// ServerListen is the server listen address (e.g., "tcp://127.0.0.1:50051" or "unix:///tmp/onekeymap.sock").
49-
ServerListen string `mapstructure:"server.listen"`
5048
// Editors holds configuration for different editors.
5149
Editors map[string]EditorConfig `mapstructure:"editors"`
5250
}
@@ -65,7 +63,6 @@ type Config struct {
6563
// - ONEKEYMAP_TELEMETRY_ENDPOINT -> telemetry.endpoint (string)
6664
// - ONEKEYMAP_TELEMETRY_HEADERS -> telemetry.headers (string, "key1=value1,key2=value2")
6765
// - ONEKEYMAP_TELEMETRY_INSECURE -> telemetry.insecure (bool)
68-
// - ONEKEYMAP_SERVER_LISTEN -> server.listen (string, e.g. "tcp://127.0.0.1:50051" or "unix:///tmp/onekeymap.sock")
6966

7067
// NewConfig initializes and returns a new Config object.
7168
// It sets defaults, binds environment variables, reads config files, and unmarshals the result.
@@ -80,7 +77,6 @@ func NewConfig(sandbox bool) (*Config, error) {
8077
// Note: We don't set default for telemetry.enabled to detect if it's explicitly configured
8178
viper.SetDefault("telemetry.endpoint", telemetryEndpoint)
8279
viper.SetDefault("telemetry.headers", telemetryHeaders)
83-
viper.SetDefault("server.listen", "")
8480

8581
// Set environment variable handling
8682
viper.SetEnvPrefix("ONEKEYMAP")

internal/cliconfig/update_telemetry_setting_test.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ telemetry:
2020
# Can also be enabled with --telemetry flag
2121
# enabled: false
2222
endpoint: "test.example.com"
23-
24-
# Other settings
25-
server:
26-
listen: ":8080"
2723
`
2824

2925
// nolint:gochecknoglobals // TestConfig for testing - all comments case
@@ -83,9 +79,6 @@ telemetry:
8379
# Can also be enabled with --telemetry flag
8480
# enabled: false
8581
endpoint: "test.example.com"
86-
# Other settings
87-
server:
88-
listen: ":8080"
8982
`,
9083
},
9184
{
@@ -110,9 +103,6 @@ telemetry:
110103
# Can also be enabled with --telemetry flag
111104
# enabled: false
112105
endpoint: "test.example.com"
113-
# Other settings
114-
server:
115-
listen: ":8080"
116106
`,
117107
},
118108
{

internal/cmd/dev_generate_base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
"strings"
1212

1313
"github.com/spf13/cobra"
14-
"github.com/xinnjie/onekeymap-cli/internal/metrics"
1514
ij "github.com/xinnjie/onekeymap-cli/internal/plugins/intellij"
1615
"github.com/xinnjie/onekeymap-cli/internal/plugins/vscode"
1716
"github.com/xinnjie/onekeymap-cli/internal/plugins/zed"
1817
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap"
1918
"github.com/xinnjie/onekeymap-cli/pkg/api/platform"
2019
"github.com/xinnjie/onekeymap-cli/pkg/api/pluginapi"
2120
"github.com/xinnjie/onekeymap-cli/pkg/mappings"
21+
"github.com/xinnjie/onekeymap-cli/pkg/metrics"
2222
)
2323

2424
type devGenerateBaseFlags struct {

internal/cmd/root.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
"github.com/spf13/cobra"
1212
"github.com/spf13/viper"
1313
"github.com/xinnjie/onekeymap-cli/internal/cliconfig"
14-
"github.com/xinnjie/onekeymap-cli/internal/metrics"
1514
"github.com/xinnjie/onekeymap-cli/internal/updatecheck"
1615
"github.com/xinnjie/onekeymap-cli/internal/views"
1716
"github.com/xinnjie/onekeymap-cli/pkg/api/exporterapi"
1817
"github.com/xinnjie/onekeymap-cli/pkg/api/importerapi"
1918
"github.com/xinnjie/onekeymap-cli/pkg/exporter"
2019
"github.com/xinnjie/onekeymap-cli/pkg/importer"
2120
"github.com/xinnjie/onekeymap-cli/pkg/mappings"
21+
"github.com/xinnjie/onekeymap-cli/pkg/metrics"
2222
"github.com/xinnjie/onekeymap-cli/pkg/registry"
2323
"golang.org/x/term"
2424
)
@@ -215,7 +215,6 @@ func Execute() {
215215
devCmd.AddCommand(NewCmdDevLookup())
216216
devCmd.AddCommand(NewCmdDevMapping())
217217
rootCmd.AddCommand(NewCmdView())
218-
// rootCmd.AddCommand(NewCmdServe(rootFlags)) // TODO: Migrate serve command
219218
rootCmd.AddCommand(NewCmdMigrate())
220219
rootCmd.AddCommand(NewCmdImport())
221220
rootCmd.AddCommand(NewCmdExport())

internal/cmd/serve.go

Lines changed: 0 additions & 235 deletions
This file was deleted.

internal/plugins/intellij/default_config_path_darwin_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212

1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
15-
"github.com/xinnjie/onekeymap-cli/internal/metrics"
1615
"github.com/xinnjie/onekeymap-cli/pkg/api/pluginapi"
1716
"github.com/xinnjie/onekeymap-cli/pkg/mappings"
17+
"github.com/xinnjie/onekeymap-cli/pkg/metrics"
1818
)
1919

2020
func TestConfigDetect_Darwin(t *testing.T) {

internal/plugins/intellij/export_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import (
1111

1212
"github.com/stretchr/testify/assert"
1313
"github.com/stretchr/testify/require"
14-
"github.com/xinnjie/onekeymap-cli/internal/metrics"
1514
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap"
1615
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap/keybinding"
1716
"github.com/xinnjie/onekeymap-cli/pkg/api/platform"
1817
"github.com/xinnjie/onekeymap-cli/pkg/api/pluginapi"
1918
"github.com/xinnjie/onekeymap-cli/pkg/mappings"
19+
"github.com/xinnjie/onekeymap-cli/pkg/metrics"
2020
)
2121

2222
func TestExportIntelliJKeymap(t *testing.T) {

internal/plugins/intellij/import.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import (
99

1010
"github.com/xinnjie/onekeymap-cli/internal/dedup"
1111
"github.com/xinnjie/onekeymap-cli/internal/imports"
12-
"github.com/xinnjie/onekeymap-cli/internal/metrics"
1312
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap"
1413
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap/keybinding"
1514
"github.com/xinnjie/onekeymap-cli/pkg/api/pluginapi"
1615
"github.com/xinnjie/onekeymap-cli/pkg/mappings"
16+
"github.com/xinnjie/onekeymap-cli/pkg/metrics"
1717
)
1818

1919
type intellijImporter struct {

internal/plugins/intellij/import_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import (
1010

1111
"github.com/stretchr/testify/assert"
1212
"github.com/stretchr/testify/require"
13-
"github.com/xinnjie/onekeymap-cli/internal/metrics"
1413
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap"
1514
"github.com/xinnjie/onekeymap-cli/pkg/api/keymap/keybinding"
1615
"github.com/xinnjie/onekeymap-cli/pkg/api/platform"
1716
"github.com/xinnjie/onekeymap-cli/pkg/api/pluginapi"
1817
"github.com/xinnjie/onekeymap-cli/pkg/mappings"
18+
"github.com/xinnjie/onekeymap-cli/pkg/metrics"
1919
)
2020

2121
func TestImportIntelliJKeymap(t *testing.T) {

0 commit comments

Comments
 (0)