docs: Add `keys` command to the CLI documentation (#3266)

This commit is contained in:
acheron 2024-09-22 23:59:38 +02:00 committed by GitHub
parent dac2271d3a
commit dbb0e88cb2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 3 deletions

View File

@ -326,7 +326,7 @@ pub enum Command {
#[clap(value_enum, long, default_value = "sbf")] #[clap(value_enum, long, default_value = "sbf")]
arch: ProgramArch, arch: ProgramArch,
}, },
/// Keypair commands. /// Program keypair commands.
Keys { Keys {
#[clap(subcommand)] #[clap(subcommand)]
subcmd: KeysCommand, subcmd: KeysCommand,
@ -376,7 +376,7 @@ pub enum Command {
pub enum KeysCommand { pub enum KeysCommand {
/// List all of the program keys. /// List all of the program keys.
List, List,
/// Sync the program's `declare_id!` pubkey with the program's actual pubkey. /// Sync program `declare_id!` pubkeys with the program's actual pubkey.
Sync { Sync {
/// Only sync the given program instead of all programs /// Only sync the given program instead of all programs
#[clap(short, long)] #[clap(short, long)]
@ -4512,7 +4512,7 @@ fn keys_list(cfg_override: &ConfigOverride) -> Result<()> {
}) })
} }
/// Sync the program's `declare_id!` pubkey with the pubkey from `target/deploy/<KEYPAIR>.json`. /// Sync program `declare_id!` pubkeys with the pubkey from `target/deploy/<KEYPAIR>.json`.
fn keys_sync(cfg_override: &ConfigOverride, program_name: Option<String>) -> Result<()> { fn keys_sync(cfg_override: &ConfigOverride, program_name: Option<String>) -> Result<()> {
with_workspace(cfg_override, |cfg| { with_workspace(cfg_override, |cfg| {
let declare_id_regex = RegexBuilder::new(r#"^(([\w]+::)*)declare_id!\("(\w*)"\)"#) let declare_id_regex = RegexBuilder::new(r#"^(([\w]+::)*)declare_id!\("(\w*)"\)"#)

View File

@ -28,6 +28,7 @@ SUBCOMMANDS:
help Prints this message or the help of the given subcommand(s) help Prints this message or the help of the given subcommand(s)
idl Commands for interacting with interface definitions idl Commands for interacting with interface definitions
init Initializes a workspace init Initializes a workspace
keys Program keypair commands
migrate Runs the deploy migration script migrate Runs the deploy migration script
new Creates a new program new Creates a new program
shell Starts a node shell with an Anchor client setup according to the local config shell Starts a node shell with an Anchor client setup according to the local config
@ -196,6 +197,26 @@ Initializes a project workspace with the following structure.
- `tests/`: Directory for JavaScript integration tests. - `tests/`: Directory for JavaScript integration tests.
- `migrations/deploy.js`: Deploy script. - `migrations/deploy.js`: Deploy script.
## Keys
Program keypair commands.
### Keys List
```shell
anchor keys list
```
List all of the program keys.
### Keys Sync
```shell
anchor keys sync
```
Sync program `declare_id!` pubkeys with the program's actual pubkey.
## Migrate ## Migrate
```shell ```shell