-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added gdown completer * Update completers/gdown_completer/cmd/actions/speed.go Co-authored-by: Ralf Steube <[email protected]> * Update speed.go * Update root.go * Update root.go --------- Co-authored-by: Ralf Steube <[email protected]>
- Loading branch information
1 parent
9f705b3
commit d205777
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
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,16 @@ | ||
package actions | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"regexp" | ||
) | ||
|
||
func ActionSpeed() carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
r := regexp.MustCompile(`^(?P<digits>\d+).*$`) | ||
if matches := r.FindStringSubmatch(c.Value); matches != nil { | ||
return carapace.ActionValues("KB", "MB", "GB").Prefix(matches[1]) | ||
} | ||
return carapace.ActionValues() | ||
}) | ||
} |
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,47 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/completers/gdown_completer/cmd/actions" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "gdown", | ||
Short: "Google Drive Public File Downloader when Curl/Wget Fails", | ||
Long: "https://github.com/wkentaro/gdown", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.Flags().BoolP("continue", "c", false, "resume getting partially-downloaded files") | ||
rootCmd.Flags().Bool("folder", false, "download entire folder instead of a single file") | ||
rootCmd.Flags().String("format", "", "Format of Google Docs, Spreadsheets, and Slides") | ||
rootCmd.Flags().Bool("fuzzy", false, "extract Google Drive's file ID") | ||
rootCmd.Flags().BoolP("help", "h", false, "show this help message and exit") | ||
rootCmd.Flags().Bool("no-check-certificate", false, "don't check the server's TLS certificate") | ||
rootCmd.Flags().Bool("no-cookies", false, "don't use cookies in ~/.cache/gdown/cookies.txt") | ||
rootCmd.Flags().StringP("output", "O", "", "output file name/path") | ||
rootCmd.Flags().String("proxy", "", "download using the specified proxy") | ||
rootCmd.Flags().BoolP("quiet", "q", false, "suppress logging except errors") | ||
rootCmd.Flags().Bool("remaining-ok", false, "asserts that is ok to download max 50 files per folder") | ||
rootCmd.Flags().String("speed", "", "download speed limit in second") | ||
rootCmd.Flags().String("user-agent", "", "User-Agent to use for downloading file") | ||
rootCmd.Flags().BoolP("version", "V", false, "display version") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"format": carapace.ActionValuesDescribed( | ||
"docx", "Google Docs", | ||
"xlsx", "Spreadsheet", | ||
"pptx", "Slides", | ||
), | ||
"output": carapace.ActionFiles(), | ||
"speed": actions.ActionSpeed(), | ||
}) | ||
} |
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,7 @@ | ||
package main | ||
|
||
import "github.com/carapace-sh/carapace-bin/completers/gdown_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |