This repository has been archived by the owner on Nov 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
1,386 additions
and
121 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package commands | ||
|
||
import ( | ||
"strconv" | ||
"time" | ||
|
||
"github.com/bndw/pick/errors" | ||
"github.com/bndw/pick/utils/clipboard" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
func init() { | ||
rootCmd.AddCommand(&cobra.Command{ | ||
Use: "clear-clipboard [after-seconds] [must-match]", | ||
Short: "Clear clipboard", | ||
Long: "The clear-clipboard command is used to clear the clipboard.", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
runCommand(ClearClipboard, cmd, args) | ||
}, | ||
Hidden: true, | ||
}) | ||
} | ||
|
||
func ClearClipboard(args []string, flags *pflag.FlagSet) error { | ||
duration, match, err := parseClearClipboardArgs(args) | ||
if err != nil { | ||
return err | ||
} | ||
time.Sleep(duration) | ||
return clipboard.ClearIfMatch(match) | ||
} | ||
|
||
func parseClearClipboardArgs(args []string) (duration time.Duration, match string, err error) { | ||
if len(args) != 2 { | ||
err = errors.ErrInvalidCommandUsage | ||
return | ||
} | ||
|
||
var secs int64 | ||
secs, err = strconv.ParseInt(args[0], 10, 64) | ||
if err != nil { | ||
return | ||
} | ||
duration = time.Duration(secs) * time.Second | ||
|
||
match = args[1] | ||
|
||
return | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.