Skip to content

Commit bc2e603

Browse files
authored
Add support for fig completions (#5669)
## 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.
1 parent 2eb6f2a commit bc2e603

File tree

10 files changed

+235
-24
lines changed

10 files changed

+235
-24
lines changed

Cargo.lock

+94-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

forc-plugins/forc-crypto/src/keys/new_key.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ use libp2p_identity::{secp256k1, Keypair, PeerId};
1111
use serde_json::json;
1212
use std::ops::Deref;
1313

14-
const ABOUT: &str = "Creates a new key for use with fuel-core";
15-
1614
forc_util::cli_examples! {
1715
crate::Command {
1816
[ Creates a new key default for block production => "forc crypto new-key" ]
@@ -21,9 +19,9 @@ forc_util::cli_examples! {
2119
}
2220
}
2321

24-
/// Generate a random new secret & public key in the format expected by fuel-core
22+
/// Creates a new key for use with fuel-core
2523
#[derive(Debug, clap::Args)]
26-
#[clap(version, about = ABOUT, after_help = help())]
24+
#[clap(version, after_help = help())]
2725
pub struct Arg {
2826
/// Key type to generate. It can either be `block-production` or `peering`.
2927
#[clap(

forc-plugins/forc-crypto/src/keys/parse_secret.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ use libp2p_identity::{secp256k1, Keypair, PeerId};
55
use serde_json::json;
66
use std::{ops::Deref, str::FromStr};
77

8-
const ABOUT: &str = "Parses a private key to view the associated public key";
9-
108
forc_util::cli_examples! {
119
crate::Command {
1210
[ Parses the secret of a block production => "forc crypto parse-secret \"f5204427d0ab9a311266c96a377f7c329cb8a41b9088225b6fcf40eefb423e28\"" ]
1311
[ Parses the secret of a peering => "forc crypto parse-secret -k peering \"f5204427d0ab9a311266c96a377f7c329cb8a41b9088225b6fcf40eefb423e28\"" ]
1412
}
1513
}
1614

17-
/// Parse a secret key to view the associated public key
15+
/// Parses a private key to view the associated public key
1816
#[derive(Debug, clap::Args)]
1917
#[clap(
2018
version,
21-
about = ABOUT,
2219
after_help = help(),
2320
)]
2421
pub struct Arg {

forc-plugins/forc-crypto/src/main.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ mod keccak256;
1616
mod keys;
1717
mod sha256;
1818

19-
const ABOUT: &str = "Forc plugin for hashing arbitrary data.";
20-
2119
fn help() -> &'static str {
2220
Box::leak(
2321
format!(
@@ -32,10 +30,10 @@ fn help() -> &'static str {
3230
)
3331
}
3432

33+
/// Forc plugin for hashing arbitrary data
3534
#[derive(Debug, Parser)]
3635
#[clap(
3736
name = "forc-crypto",
38-
about = ABOUT,
3937
after_help = help(),
4038
version
4139
)]

forc-plugins/forc-doc/src/cli.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
use clap::Parser;
33
use forc_pkg::source::IPFSNode;
44

5-
const ABOUT: &str = "Forc plugin for building a Sway package's documentation";
6-
75
forc_util::cli_examples! {
86
crate::Command {
97
[ Build the docs for a project in the current path => "forc doc"]
@@ -14,10 +12,10 @@ forc_util::cli_examples! {
1412
}
1513
}
1614

15+
/// Forc plugin for building a Sway package's documentation
1716
#[derive(Debug, Parser, Default)]
1817
#[clap(
1918
name = "forc-doc",
20-
about = ABOUT,
2119
after_help = help(),
2220
version
2321
)]

forc-plugins/forc-fmt/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ forc_util::cli_examples! {
3636
#[derive(Debug, Parser)]
3737
#[clap(
3838
name = "forc-fmt",
39-
about = "Forc plugin for running the Sway code formatter.",
39+
about = "Forc plugin for running the Sway code formatter",
4040
after_help = help(),
4141
version
4242
)]

forc-plugins/forc-lsp/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use clap::Parser;
1111
#[derive(Debug, Parser)]
1212
#[clap(
1313
name = "forc-lsp",
14-
about = "Forc plugin for the Sway LSP (Language Server Protocol) implementation.",
14+
about = "Forc plugin for the Sway LSP (Language Server Protocol) implementation",
1515
version
1616
)]
1717
struct App {}

forc/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ansi_term = "0.12"
2222
anyhow = "1.0.41"
2323
clap = { version = "3.1", features = ["cargo", "derive", "env"] }
2424
clap_complete = "3.1"
25+
clap_complete_fig = "3.1"
2526
forc-pkg = { version = "0.52.1", path = "../forc-pkg" }
2627
forc-test = { version = "0.52.1", path = "../forc-test" }
2728
forc-tracing = { version = "0.52.1", path = "../forc-tracing" }
@@ -50,3 +51,6 @@ default = []
5051
test = []
5152
util = []
5253
uwu = ["uwuify"]
54+
55+
[dev-dependencies]
56+
completest-pty = "0.5.0"

0 commit comments

Comments
 (0)