Skip to content

Commit

Permalink
Add support for fig completions (#5669)
Browse files Browse the repository at this point in the history
## Description

This fixes #5474

This is the first part of #5612, which will be split into several
smaller PRs


## Checklist

- [x] I have linked to any relevant issues.
- [x] I have commented my code, particularly in hard-to-understand
areas.
- [x] I have updated the documentation where relevant (API docs, the
reference, and the Sway book).
- [x] I have added tests that prove my fix is effective or that my
feature works.
- [x] I have added (or requested a maintainer to add) the necessary
`Breaking*` or `New Feature` labels where relevant.
- [x] I have done my best to ensure that my PR adheres to [the Fuel Labs
Code Review
Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md).
- [x] I have requested a review from the relevant team or maintainers.
  • Loading branch information
crodas committed Apr 4, 2024
1 parent 2eb6f2a commit bc2e603
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 24 deletions.
95 changes: 94 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions forc-plugins/forc-crypto/src/keys/new_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ use libp2p_identity::{secp256k1, Keypair, PeerId};
use serde_json::json;
use std::ops::Deref;

const ABOUT: &str = "Creates a new key for use with fuel-core";

forc_util::cli_examples! {
crate::Command {
[ Creates a new key default for block production => "forc crypto new-key" ]
Expand All @@ -21,9 +19,9 @@ forc_util::cli_examples! {
}
}

/// Generate a random new secret & public key in the format expected by fuel-core
/// Creates a new key for use with fuel-core
#[derive(Debug, clap::Args)]
#[clap(version, about = ABOUT, after_help = help())]
#[clap(version, after_help = help())]
pub struct Arg {
/// Key type to generate. It can either be `block-production` or `peering`.
#[clap(
Expand Down
5 changes: 1 addition & 4 deletions forc-plugins/forc-crypto/src/keys/parse_secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ use libp2p_identity::{secp256k1, Keypair, PeerId};
use serde_json::json;
use std::{ops::Deref, str::FromStr};

const ABOUT: &str = "Parses a private key to view the associated public key";

forc_util::cli_examples! {
crate::Command {
[ Parses the secret of a block production => "forc crypto parse-secret \"f5204427d0ab9a311266c96a377f7c329cb8a41b9088225b6fcf40eefb423e28\"" ]
[ Parses the secret of a peering => "forc crypto parse-secret -k peering \"f5204427d0ab9a311266c96a377f7c329cb8a41b9088225b6fcf40eefb423e28\"" ]
}
}

/// Parse a secret key to view the associated public key
/// Parses a private key to view the associated public key
#[derive(Debug, clap::Args)]
#[clap(
version,
about = ABOUT,
after_help = help(),
)]
pub struct Arg {
Expand Down
4 changes: 1 addition & 3 deletions forc-plugins/forc-crypto/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ mod keccak256;
mod keys;
mod sha256;

const ABOUT: &str = "Forc plugin for hashing arbitrary data.";

fn help() -> &'static str {
Box::leak(
format!(
Expand All @@ -32,10 +30,10 @@ fn help() -> &'static str {
)
}

/// Forc plugin for hashing arbitrary data
#[derive(Debug, Parser)]
#[clap(
name = "forc-crypto",
about = ABOUT,
after_help = help(),
version
)]
Expand Down
4 changes: 1 addition & 3 deletions forc-plugins/forc-doc/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
use clap::Parser;
use forc_pkg::source::IPFSNode;

const ABOUT: &str = "Forc plugin for building a Sway package's documentation";

forc_util::cli_examples! {
crate::Command {
[ Build the docs for a project in the current path => "forc doc"]
Expand All @@ -14,10 +12,10 @@ forc_util::cli_examples! {
}
}

/// Forc plugin for building a Sway package's documentation
#[derive(Debug, Parser, Default)]
#[clap(
name = "forc-doc",
about = ABOUT,
after_help = help(),
version
)]
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-fmt/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ forc_util::cli_examples! {
#[derive(Debug, Parser)]
#[clap(
name = "forc-fmt",
about = "Forc plugin for running the Sway code formatter.",
about = "Forc plugin for running the Sway code formatter",
after_help = help(),
version
)]
Expand Down
2 changes: 1 addition & 1 deletion forc-plugins/forc-lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use clap::Parser;
#[derive(Debug, Parser)]
#[clap(
name = "forc-lsp",
about = "Forc plugin for the Sway LSP (Language Server Protocol) implementation.",
about = "Forc plugin for the Sway LSP (Language Server Protocol) implementation",
version
)]
struct App {}
Expand Down
4 changes: 4 additions & 0 deletions forc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ansi_term = "0.12"
anyhow = "1.0.41"
clap = { version = "3.1", features = ["cargo", "derive", "env"] }
clap_complete = "3.1"
clap_complete_fig = "3.1"
forc-pkg = { version = "0.52.1", path = "../forc-pkg" }
forc-test = { version = "0.52.1", path = "../forc-test" }
forc-tracing = { version = "0.52.1", path = "../forc-tracing" }
Expand Down Expand Up @@ -50,3 +51,6 @@ default = []
test = []
util = []
uwu = ["uwuify"]

[dev-dependencies]
completest-pty = "0.5.0"
Loading

0 comments on commit bc2e603

Please sign in to comment.