gosuki/cmd/firefox_commands.go

93 lines
1.6 KiB
Go
Raw Normal View History

2019-02-26 18:42:56 +00:00
//TODO: add cli options to set/get options
2019-02-26 10:23:00 +00:00
package cmd
import (
"fmt"
"path/filepath"
2020-08-12 18:14:27 +00:00
"git.sp4ke.com/sp4ke/gomark/logging"
"git.sp4ke.com/sp4ke/gomark/mozilla"
2019-02-26 10:23:00 +00:00
2020-08-12 18:13:01 +00:00
"github.com/urfave/cli/v2"
2019-02-26 10:23:00 +00:00
)
var fflog = logging.GetLogger("FF")
var ffUnlockVFSCmd = cli.Command{
Name: "unlock",
Aliases: []string{"u"},
Action: ffUnlockVFS,
}
var ffCheckVFSCmd = cli.Command{
Name: "check",
Aliases: []string{"c"},
Action: ffCheckVFS,
}
var ffVFSCommands = cli.Command{
Name: "vfs",
Usage: "VFS locking commands",
Subcommands: []*cli.Command{
&ffUnlockVFSCmd,
&ffCheckVFSCmd,
2019-02-26 10:23:00 +00:00
},
}
var ffListProfilesCmd = cli.Command{
Name: "list",
Aliases: []string{"l"},
Action: ffListProfiles,
}
var ffProfilesCmds = cli.Command{
Name: "profiles",
Aliases: []string{"p"},
Usage: "Profiles commands",
Subcommands: []*cli.Command{
&ffListProfilesCmd,
2019-02-26 10:23:00 +00:00
},
}
var FirefoxCmds = &cli.Command{
2019-02-26 10:23:00 +00:00
Name: "firefox",
Aliases: []string{"ff"},
Usage: "firefox related commands",
Subcommands: []*cli.Command{
&ffVFSCommands,
&ffProfilesCmds,
2019-02-26 10:23:00 +00:00
},
//Action: unlockFirefox,
}
func ffListProfiles(c *cli.Context) error {
2019-02-26 10:23:00 +00:00
profs, err := mozilla.FirefoxProfileManager.GetProfiles()
if err != nil {
return err
2019-02-26 10:23:00 +00:00
}
for _, p := range profs {
2019-02-26 18:41:02 +00:00
fmt.Printf("<%s>: %s\n", p.Name, filepath.Join(mozilla.GetBookmarkDir(), p.Path))
2019-02-26 10:23:00 +00:00
}
2019-02-26 18:41:02 +00:00
return nil
2019-02-26 10:23:00 +00:00
}
func ffCheckVFS(c *cli.Context) error {
2019-02-26 10:23:00 +00:00
err := mozilla.CheckVFSLock()
if err != nil {
return err
2019-02-26 10:23:00 +00:00
}
return nil
2019-02-26 10:23:00 +00:00
}
func ffUnlockVFS(c *cli.Context) error {
2019-02-26 10:23:00 +00:00
err := mozilla.UnlockPlaces()
if err != nil {
return err
2019-02-26 10:23:00 +00:00
}
return nil
2019-02-26 10:23:00 +00:00
}