Skip to content

Commit

Permalink
Add download actions
Browse files Browse the repository at this point in the history
  • Loading branch information
deanishe committed Jan 7, 2020
1 parent fc469d0 commit daed667
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 2 deletions.
39 changes: 38 additions & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ var (
LongHelp: wrap(`Show workflow status, info and options.`),
Exec: runStatus,
}

// open file in default application
openCmd = &ffcli.Command{
Name: "open",
Usage: "alfred-firefox open <path>",
ShortHelp: "open file in default application",
LongHelp: wrap(`Open file in default application.`),
Exec: runOpen,
}

// reveal file in Finder
revealCmd = &ffcli.Command{
Name: "reveal",
Usage: "alfred-firefox reveal <path>",
ShortHelp: "reveal file in Finder",
LongHelp: wrap(`Reveal file in Finder.`),
Exec: runReveal,
}
)

func runOpenURL(_ []string) error {
Expand Down Expand Up @@ -472,15 +490,34 @@ func runDownloads(_ []string) error {
Subtitle(util.PrettyPath(dl.Path)).
Arg(dl.Path).
UID(dl.Path).
IsFile(true).
Icon(&aw.Icon{Value: dl.Path, Type: aw.IconTypeFileIcon}).
Valid(true)
Valid(true).
Var("CMD", "open").
NewModifier(aw.ModCmd).
Subtitle("Reveal in Finder").
Var("CMD", "reveal")
}

wf.WarnEmpty("Nothing Found", "Try a different query?")
wf.SendFeedback()
return nil
}

// open file in default application
func runOpen(args []string) error {
path := args[0]
log.Printf("opening file %q ...", util.PrettyPath(path))
return exec.Command("/usr/bin/open", path).Run()
}

// reveal file in Finder
func runReveal(args []string) error {
path := args[0]
log.Printf("revealing file %q in Finder ...", util.PrettyPath(path))
return exec.Command("/usr/bin/open", "-R", path).Run()
}

// run update check in background
func checkForUpdate() {
if wf.UpdateCheckDue() && !wf.IsRunning("update") {
Expand Down
Binary file modified icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons.afdesign
Binary file not shown.
Binary file modified icons/bookmark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/bookmarklet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/error.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/history.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/more.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/tab.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/update-available.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/update-ok.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/url.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/warning.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
package main

// TODO: implement setup (save native application manifest)
// TODO: implement tab scripts (injectable JS)?
// TODO: package extension

import (
Expand Down Expand Up @@ -92,6 +91,8 @@ func init() {
currentTabCmd,
downloadsCmd,
historyCmd,
openCmd,
revealCmd,
runBookmarkletCmd,
serveCmd,
statusCmd,
Expand Down

0 comments on commit daed667

Please sign in to comment.