Skip to content

Commit 0752876

Browse files
committed
rename to rescan
1 parent 5786817 commit 0752876

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

main.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ var version string
1313

1414
func main() {
1515
var identifier string
16-
var noRebuildLaunchServices bool
16+
var noRescanLaunchServices bool
1717

1818
var rootCmd = &cobra.Command{
1919
Use: "default-browser",
2020
Short: "A cli tool to set the default browser on macOS",
2121
RunE: func(cmd *cobra.Command, args []string) error {
22-
return setDefault(identifier, noRebuildLaunchServices)
22+
return setDefault(identifier, noRescanLaunchServices)
2323
},
2424
}
2525

2626
rootCmd.Flags().StringVar(&identifier, "identifier", "com.google.chrome", "An identifier for the application")
27-
rootCmd.Flags().BoolVar(&noRebuildLaunchServices, "no-rebuild-launchservices", false, "Do not rebuild launch services. Only use if you are experiencing issues with System Settings not displaying correctly after a reboot.")
27+
rootCmd.Flags().BoolVar(&noRescanLaunchServices, "no-rebuild-launchservices", false, "Do not rescan launch services. Only use if you are experiencing issues with System Settings not displaying correctly after a reboot.")
28+
rootCmd.Flags().BoolVar(&noRescanLaunchServices, "no-rescan-launchservices", false, "Legacy: same as --no-rebuild-launchservices")
2829

2930
rootCmd.Version = version
3031
rootCmd.SetVersionTemplate("default-browser version {{.Version}}\n")
@@ -35,7 +36,7 @@ func main() {
3536
}
3637
}
3738

38-
func setDefault(identifier string, noRebuildLaunchServices bool) error {
39+
func setDefault(identifier string, noRescanLaunchServices bool) error {
3940
if identifier == "" {
4041
return fmt.Errorf("identifier cannot be empty")
4142
}
@@ -50,7 +51,7 @@ func setDefault(identifier string, noRebuildLaunchServices bool) error {
5051
return err
5152
}
5253

53-
err = launchservices.ModifyLS(c, identifier, noRebuildLaunchServices)
54+
err = launchservices.ModifyLS(c, identifier, noRescanLaunchServices)
5455
if err != nil {
5556
return err
5657
}

pkg/launchservices/launchservices.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
const lsregister = "/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister"
1111

12-
func ModifyLS(c client.Client, identifier string, noRebuildLaunchServices bool) error {
12+
func ModifyLS(c client.Client, identifier string, noRescanLaunchServices bool) error {
1313
plist, err := GetPlist(c.PlistLocation)
1414
if err != nil {
1515
return err
@@ -40,7 +40,7 @@ func ModifyLS(c client.Client, identifier string, noRebuildLaunchServices bool)
4040
return nil
4141
}
4242

43-
err = rebuildLaunchServices(c, noRebuildLaunchServices)
43+
err = rescanLaunchServices(c, noRescanLaunchServices)
4444
if err != nil {
4545
return err
4646
}
@@ -53,8 +53,8 @@ func ModifyLS(c client.Client, identifier string, noRebuildLaunchServices bool)
5353
return nil
5454
}
5555

56-
func rebuildLaunchServices(c client.Client, noRebuildLaunchServices bool) error {
57-
if !noRebuildLaunchServices {
56+
func rescanLaunchServices(c client.Client, noRescanLaunchServices bool) error {
57+
if !noRescanLaunchServices {
5858
_, err := c.Runner.RunCmd(lsregister, "-gc", "-R", "-all", "user,system,local,network")
5959
if err != nil {
6060
return err

pkg/launchservices/launchservices_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/stretchr/testify/assert"
1010
)
1111

12-
func TestRebuildLaunchServices(t *testing.T) {
12+
func TestRescanLaunchServices(t *testing.T) {
1313
mockRunner := utils.MockCmdRunner{
1414
Output: "",
1515
Err: nil,
@@ -19,11 +19,11 @@ func TestRebuildLaunchServices(t *testing.T) {
1919
Runner: mockRunner,
2020
}
2121

22-
err := rebuildLaunchServices(mockClient, false)
23-
assert.NoError(t, err, "rebuildLaunchServices should not return an error")
22+
err := rescanLaunchServices(mockClient, false)
23+
assert.NoError(t, err, "rescanLaunchServices should not return an error")
2424

25-
err = rebuildLaunchServices(mockClient, true)
26-
assert.NoError(t, err, "rebuildLaunchServices should not return an error when noRebuildLaunchServices is true")
25+
err = rescanLaunchServices(mockClient, true)
26+
assert.NoError(t, err, "rescanLaunchServices should not return an error when noRebuildLaunchServices is true")
2727
}
2828

2929
func TestKilllsd(t *testing.T) {

0 commit comments

Comments
 (0)