Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cargo-metadata #1332

Merged
merged 1 commit into from
Sep 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions completers/cargo-metadata_completer/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/tools/cargo"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)

var rootCmd = &cobra.Command{
Use: "cargo-metadata",
Short: "Output the resolved dependencies of a package",
Long: "https://doc.rust-lang.org/cargo/commands/cargo-metadata.html",
Run: func(cmd *cobra.Command, args []string) {},
}

func Execute() error {
return rootCmd.Execute()
}
func init() {
carapace.Gen(rootCmd).Standalone()

rootCmd.Flags().StringS("Z", "Z", "", "Unstable (nightly-only) flags to Cargo, see 'cargo -Z help'")
rootCmd.Flags().Bool("all-features", false, "Activate all available features")
rootCmd.Flags().String("color", "", "Coloring: auto, always, never")
rootCmd.Flags().String("config", "", "Override a configuration value")
rootCmd.Flags().StringP("features", "F", "", "Space or comma separated list of features to activate")
rootCmd.Flags().String("filter-platform", "", "Only include resolve dependencies matching the given")
rootCmd.Flags().String("format-version", "", "Format version [possible values: 1]")
rootCmd.Flags().Bool("frozen", false, "Require Cargo.lock and cache are up to date")
rootCmd.Flags().BoolP("help", "h", false, "Print help information")
rootCmd.Flags().Bool("locked", false, "Require Cargo.lock is up to date")
rootCmd.Flags().String("manifest-path", "", "Path to Cargo.toml")
rootCmd.Flags().Bool("no-default-features", false, "Do not activate the `default` feature")
rootCmd.Flags().Bool("no-deps", false, "Output information only about the workspace members and don't")
rootCmd.Flags().Bool("offline", false, "Run without accessing the network")
rootCmd.Flags().BoolP("quiet", "q", false, "Do not print cargo log messages")
rootCmd.Flags().BoolP("verbose", "v", false, "Use verbose output (-vv very verbose/build.rs output)")

// TODO more flags
carapace.Gen(rootCmd).FlagCompletion(carapace.ActionMap{
"Z": cargo.ActionNightlyFlags(),
"color": carapace.ActionValues("auto", "always", "never").StyleF(style.ForKeyword),
"features": carapace.ActionMultiParts(",", func(c carapace.Context) carapace.Action {
return cargo.ActionFeatures(rootCmd.Flag("manifest-path").Value.String()).Invoke(c).Filter(c.Parts).ToA()
}),
"format-version": carapace.ActionValues("1"),
"manifest-path": carapace.ActionFiles(),
})
}
7 changes: 7 additions & 0 deletions completers/cargo-metadata_completer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "github.com/rsteube/carapace-bin/completers/cargo-metadata_completer/cmd"

func main() {
cmd.Execute()
}