Skip to content

Commit

Permalink
Merge pull request #1740 from rsteube/cargo-updates-1.72
Browse files Browse the repository at this point in the history
cargo: updates from 1.72.0
  • Loading branch information
rsteube authored Jul 17, 2023
2 parents d8efb09 + 7c52c59 commit 100c84b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions completers/cargo_completer/cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func init() {
addCmd.Flags().StringSliceP("features", "F", []string{}, "Space or comma separated list of features to activate")
addCmd.Flags().String("git", "", "Git repository location")
addCmd.Flags().BoolP("help", "h", false, "Print help (see more with '--help')")
addCmd.Flags().Bool("ignore-rust-version", false, "Ignore `rust-version` specification in packages (unstable)")
addCmd.Flags().String("manifest-path", "", "Path to Cargo.toml")
addCmd.Flags().Bool("no-default-features", false, "Disable the default features")
addCmd.Flags().Bool("no-optional", false, "Mark the dependency as required")
Expand Down
1 change: 1 addition & 0 deletions completers/cargo_completer/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func init() {
installCmd.Flags().BoolP("force", "f", false, "Force overwriting existing crates or binaries")
installCmd.Flags().String("git", "", "Git URL to install the specified crate from")
installCmd.Flags().BoolP("help", "h", false, "Print help")
installCmd.Flags().Bool("ignore-rust-version", false, "Ignore `rust-version` specification in packages")
installCmd.Flags().String("index", "", "Registry index to install from")
installCmd.Flags().StringP("jobs", "j", "", "Number of parallel jobs, defaults to # of CPUs")
installCmd.Flags().Bool("keep-going", false, "Do not abort the build as soon as there is an error (unstable)")
Expand Down
25 changes: 25 additions & 0 deletions completers/cargo_completer/cmd/readManifest.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/spf13/cobra"
)

var readManifestCmd = &cobra.Command{
Use: "read-manifest",
Short: "Print a JSON representation of a Cargo.toml manifest.",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(readManifestCmd).Standalone()

readManifestCmd.Flags().BoolP("help", "h", false, "Print help")
readManifestCmd.Flags().String("manifest-path", "", "Path to Cargo.toml")
readManifestCmd.Flags().BoolP("quiet", "q", false, "Do not print cargo log messages")
rootCmd.AddCommand(readManifestCmd)

carapace.Gen(readManifestCmd).FlagCompletion(carapace.ActionMap{
"manifest-path": carapace.ActionFiles(),
})
}
7 changes: 7 additions & 0 deletions completers/cargo_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/rsteube/carapace-bridge/pkg/actions/bridge"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -44,6 +45,7 @@ func init() {

carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().StringP("C", "C", "", "Change to DIRECTORY before doing anything (nightly-only)")
rootCmd.PersistentFlags().StringSliceP("Z", "Z", []string{}, "Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for details")
rootCmd.PersistentFlags().String("color", "", "Coloring: auto, always, never")
rootCmd.PersistentFlags().StringSlice("config", []string{}, "Override a configuration value")
Expand All @@ -58,6 +60,7 @@ func init() {
rootCmd.Flags().BoolP("version", "V", false, "Print version info and exit")

carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"C": carapace.ActionDirectories(),
"Z": cargo.ActionNightlyFlags(),
"color": carapace.ActionValues("auto", "never", "always").StyleF(style.ForKeyword),
})
Expand Down Expand Up @@ -86,6 +89,10 @@ func init() {
}
}
})

carapace.Gen(rootCmd).PreInvoke(func(cmd *cobra.Command, flag *pflag.Flag, action carapace.Action) carapace.Action {
return action.Chdir(rootCmd.Flag("C").Value.String())
})
}

func groupFor(name string) string {
Expand Down

0 comments on commit 100c84b

Please sign in to comment.