Added patool completer (#2751)

* Added patool completer

* patool: added recompress

---------

Co-authored-by: rsteube <rsteube@users.noreply.github.com>
This commit is contained in:
Saurabh Kushwah 2025-04-09 00:39:02 +05:30 committed by GitHub
parent 63483c0976
commit a283046a3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 259 additions and 0 deletions

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var createCmd = &cobra.Command{
Use: "create",
Short: "create an archive",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(createCmd).Standalone()
createCmd.Flags().String("password", "", "password to encrypt files")
rootCmd.AddCommand(createCmd)
carapace.Gen(createCmd).PositionalAnyCompletion(
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var diffCmd = &cobra.Command{
Use: "diff",
Short: "show differences between two archives",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(diffCmd).Standalone()
rootCmd.AddCommand(diffCmd)
carapace.Gen(diffCmd).PositionalCompletion(
carapace.ActionFiles(),
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,28 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var extractCmd = &cobra.Command{
Use: "extract",
Short: "extract one or more archives",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(extractCmd).Standalone()
extractCmd.Flags().String("outdir", "", "output directory to extract to")
extractCmd.Flags().String("password", "", "password for encrypted files")
rootCmd.AddCommand(extractCmd)
carapace.Gen(extractCmd).FlagCompletion(carapace.ActionMap{
"outdir": carapace.ActionDirectories(),
})
carapace.Gen(extractCmd).PositionalAnyCompletion(
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,18 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var formatsCmd = &cobra.Command{
Use: "formats",
Short: "show supported archive formats",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(formatsCmd).Standalone()
rootCmd.AddCommand(formatsCmd)
}

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var listCmd = &cobra.Command{
Use: "list",
Short: "list members or one or more archives",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(listCmd).Standalone()
listCmd.Flags().String("password", "", "password for encrypted files")
rootCmd.AddCommand(listCmd)
carapace.Gen(listCmd).PositionalAnyCompletion(
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,22 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var recompressCmd = &cobra.Command{
Use: "recompress",
Short: "recompress an archive",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(recompressCmd).Standalone()
rootCmd.AddCommand(recompressCmd)
carapace.Gen(recompressCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var repackCmd = &cobra.Command{
Use: "repack",
Short: "repack an archive to a different format",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(repackCmd).Standalone()
rootCmd.AddCommand(repackCmd)
carapace.Gen(repackCmd).PositionalCompletion(
carapace.ActionFiles(),
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,27 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "patool",
Short: "An archive file manager",
Long: "http://wummel.github.io/patool/",
Run: func(cmd *cobra.Command, args []string) {},
}
func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()
rootCmd.Flags().Bool("non-interactive", false, "don't query for user input")
rootCmd.Flags().CountP("quiet", "q", "quiet operation")
rootCmd.Flags().CountP("verbose", "v", "verbose operation")
rootCmd.PersistentFlags().BoolP("help", "h", false, "show this help message and exit")
}

View File

@ -0,0 +1,24 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var searchCmd = &cobra.Command{
Use: "search",
Short: "search contents of archive members",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(searchCmd).Standalone()
searchCmd.Flags().String("password", "", "password for encrypted files")
rootCmd.AddCommand(searchCmd)
carapace.Gen(searchCmd).PositionalCompletion(
carapace.ActionValues(),
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,23 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var testCmd = &cobra.Command{
Use: "test",
Short: "test an archive",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(testCmd).Standalone()
testCmd.Flags().String("password", "", "password for encrypted files")
rootCmd.AddCommand(testCmd)
carapace.Gen(testCmd).PositionalAnyCompletion(
carapace.ActionFiles(),
)
}

View File

@ -0,0 +1,18 @@
package cmd
import (
"github.com/carapace-sh/carapace"
"github.com/spf13/cobra"
)
var versionCmd = &cobra.Command{
Use: "version",
Short: "print version information",
Run: func(cmd *cobra.Command, args []string) {},
}
func init() {
carapace.Gen(versionCmd).Standalone()
rootCmd.AddCommand(versionCmd)
}

View File

@ -0,0 +1,7 @@
package main
import "github.com/carapace-sh/carapace-bin/completers/patool_completer/cmd"
func main() {
cmd.Execute()
}