-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
15 changed files
with
326 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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var completionCmd = &cobra.Command{ | ||
Use: "completion", | ||
Short: "Generate the autocompletion script for the specified shell", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(completionCmd).Standalone() | ||
|
||
rootCmd.AddCommand(completionCmd) | ||
} |
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,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var completion_bashCmd = &cobra.Command{ | ||
Use: "bash", | ||
Short: "Generate the autocompletion script for bash", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(completion_bashCmd).Standalone() | ||
|
||
completion_bashCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions") | ||
completionCmd.AddCommand(completion_bashCmd) | ||
} |
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,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var completion_fishCmd = &cobra.Command{ | ||
Use: "fish", | ||
Short: "Generate the autocompletion script for fish", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(completion_fishCmd).Standalone() | ||
|
||
completion_fishCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions") | ||
completionCmd.AddCommand(completion_fishCmd) | ||
} |
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,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var completion_powershellCmd = &cobra.Command{ | ||
Use: "powershell", | ||
Short: "Generate the autocompletion script for powershell", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(completion_powershellCmd).Standalone() | ||
|
||
completion_powershellCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions") | ||
completionCmd.AddCommand(completion_powershellCmd) | ||
} |
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,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var completion_zshCmd = &cobra.Command{ | ||
Use: "zsh", | ||
Short: "Generate the autocompletion script for zsh", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(completion_zshCmd).Standalone() | ||
|
||
completion_zshCmd.Flags().Bool("no-descriptions", false, "disable completion descriptions") | ||
completionCmd.AddCommand(completion_zshCmd) | ||
} |
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,31 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/saw" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var getCmd = &cobra.Command{ | ||
Use: "get <log group>", | ||
Short: "Get log events", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(getCmd).Standalone() | ||
|
||
getCmd.Flags().Bool("expand", false, "indent JSON log messages") | ||
getCmd.Flags().String("filter", "", "event filter pattern") | ||
getCmd.Flags().Bool("invert", false, "invert colors for light terminal themes") | ||
getCmd.Flags().String("prefix", "", "log group prefix filter") | ||
getCmd.Flags().Bool("pretty", false, "print timestamp and stream name prefix") | ||
getCmd.Flags().Bool("rawString", false, "print JSON strings without escaping") | ||
getCmd.Flags().String("start", "", "start getting the logs from this point") | ||
getCmd.Flags().String("stop", "", "stop getting the logs at this point") | ||
rootCmd.AddCommand(getCmd) | ||
|
||
carapace.Gen(getCmd).PositionalCompletion( | ||
saw.ActionGroups(), | ||
) | ||
} |
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,19 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var groupsCmd = &cobra.Command{ | ||
Use: "groups", | ||
Short: "List log groups", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(groupsCmd).Standalone() | ||
|
||
groupsCmd.Flags().String("prefix", "", "log group prefix filter") | ||
rootCmd.AddCommand(groupsCmd) | ||
} |
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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var helpCmd = &cobra.Command{ | ||
Use: "help [command]", | ||
Short: "Help about any command", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(helpCmd).Standalone() | ||
|
||
rootCmd.AddCommand(helpCmd) | ||
} |
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,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/aws" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "saw <command>", | ||
Short: "A fast, multipurpose tool for AWS CloudWatch Logs", | ||
Long: "https://github.com/TylerBrock/saw", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func Execute() error { | ||
return rootCmd.Execute() | ||
} | ||
|
||
func init() { | ||
carapace.Gen(rootCmd).Standalone() | ||
|
||
rootCmd.PersistentFlags().String("endpoint-url", "", "override default endpoint URL") | ||
rootCmd.PersistentFlags().String("profile", "", "override default AWS profile") | ||
rootCmd.PersistentFlags().String("region", "", "override profile AWS region") | ||
|
||
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{ | ||
"profile": aws.ActionProfiles(), | ||
"region": aws.ActionRegions(), | ||
}) | ||
|
||
carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
if f := cmd.Flag("profile"); f.Changed { | ||
c.Setenv("AWS_PROFILE", f.Value.String()) | ||
} | ||
if f := cmd.Flag("region"); f.Changed { | ||
c.Setenv("AWS_REGION", f.Value.String()) | ||
} | ||
return action.Invoke(c).ToA() | ||
}) | ||
}) | ||
} |
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,26 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/saw" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var streamsCmd = &cobra.Command{ | ||
Use: "streams <log group>", | ||
Short: "List streams in log group", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(streamsCmd).Standalone() | ||
|
||
streamsCmd.Flags().Bool("descending", false, "order streams descending") | ||
streamsCmd.Flags().String("orderBy", "", "order streams by LogStreamName or LastEventTime") | ||
streamsCmd.Flags().String("prefix", "", "stream prefix filter") | ||
rootCmd.AddCommand(streamsCmd) | ||
|
||
carapace.Gen(streamsCmd).PositionalCompletion( | ||
saw.ActionGroups(), | ||
) | ||
} |
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,18 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var versionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Prints the version string", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(versionCmd).Standalone() | ||
|
||
rootCmd.AddCommand(versionCmd) | ||
} |
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,29 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/carapace-sh/carapace" | ||
"github.com/carapace-sh/carapace-bin/pkg/actions/tools/saw" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var watchCmd = &cobra.Command{ | ||
Use: "watch <log group>", | ||
Short: "Continuously stream log events", | ||
Run: func(cmd *cobra.Command, args []string) {}, | ||
} | ||
|
||
func init() { | ||
carapace.Gen(watchCmd).Standalone() | ||
|
||
watchCmd.Flags().Bool("expand", false, "indent JSON log messages") | ||
watchCmd.Flags().String("filter", "", "event filter pattern") | ||
watchCmd.Flags().Bool("invert", false, "invert colors for light terminal themes") | ||
watchCmd.Flags().String("prefix", "", "log stream prefix filter") | ||
watchCmd.Flags().Bool("raw", false, "print raw log event without timestamp or stream prefix") | ||
watchCmd.Flags().Bool("rawString", false, "print JSON strings without escaping") | ||
rootCmd.AddCommand(watchCmd) | ||
|
||
carapace.Gen(watchCmd).PositionalCompletion( | ||
saw.ActionGroups(), | ||
) | ||
} |
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/saw_completer/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
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,20 @@ | ||
package saw | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/carapace-sh/carapace" | ||
) | ||
|
||
// ActionGroups completes log groups. | ||
// | ||
// lambda/one | ||
// ecs/two | ||
func ActionGroups() carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.ActionExecCommand("saw", "groups", "--prefix", c.Value)(func(output []byte) carapace.Action { | ||
lines := strings.Split(string(output), "\n") | ||
return carapace.ActionValues(lines...) | ||
}) | ||
}).Tag("groups") | ||
} |
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,20 @@ | ||
package saw | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/carapace-sh/carapace" | ||
) | ||
|
||
// ActionStreams completes log streams. | ||
// | ||
// streamOne | ||
// streamTwo | ||
func ActionStreams(group string) carapace.Action { | ||
return carapace.ActionCallback(func(c carapace.Context) carapace.Action { | ||
return carapace.ActionExecCommand("saw", "streams", "--prefix", c.Value, group)(func(output []byte) carapace.Action { | ||
lines := strings.Split(string(output), "\n") | ||
return carapace.ActionValues(lines...) | ||
}) | ||
}).Tag("streams") | ||
} |