nifty_cli/
args.rs

1use std::path::PathBuf;
2
3use clap::{Parser, Subcommand};
4use solana_program::pubkey::Pubkey;
5
6#[derive(Parser)]
7#[clap(author, version, about)]
8pub struct Args {
9    /// Path to the keypair file.
10    #[arg(short, long, global = true)]
11    pub keypair_path: Option<PathBuf>,
12
13    /// RPC URL for the Solana cluster.
14    #[arg(short, long, global = true)]
15    pub rpc_url: Option<String>,
16
17    #[clap(subcommand)]
18    pub command: Commands,
19}
20
21#[derive(Clone, Subcommand)]
22pub enum Commands {
23    /// Burn an asset.
24    Burn {
25        /// The asset to burn.
26        asset: Pubkey,
27
28        /// The recipient to receive reclaimed rent. Defaults to the signer.
29        recipient: Option<Pubkey>,
30    },
31    /// Create an asset with extension data.
32    Mint { asset_file_path: PathBuf },
33    /// Create a batch of assets with extension data.
34    MintBatch {
35        asset_files_dir: PathBuf,
36
37        /// Delay in ms between transactions.
38        #[arg(long, default_value = "100")]
39        delay: u64,
40    },
41    /// Create a basic asset with no extensions.
42    Create {
43        /// The name of the asset.
44        #[arg(short, long)]
45        name: String,
46
47        /// Path to the mint keypair file
48        #[arg(short, long)]
49        asset_keypair_path: Option<PathBuf>,
50
51        /// Create the asset as immutable.
52        #[arg(long)]
53        immutable: bool,
54
55        /// Owner of the created asset, defaults to authority pubkey.
56        #[arg(short, long)]
57        owner: Option<Pubkey>,
58    },
59    /// Get an asset account's data and decode it.
60    Decode {
61        /// The asset to decode.
62        asset: Pubkey,
63
64        /// The field to decode.
65        /// If not specified, the entire asset will be decoded.
66        #[arg(short, long)]
67        field: Option<String>,
68
69        /// Output the raw account data.
70        #[arg(long)]
71        raw: bool,
72    },
73    /// Set a delegate on an asset with specific roles.
74    Approve {
75        /// The asset to delegate.
76        asset: Pubkey,
77
78        /// The address to delegate to.
79        delegate: Pubkey,
80
81        /// The role for the delegate to have: "burn", "lock", "transfer".
82        /// Specify each one separately: --role burn --role lock --role transfer
83        #[arg(short = 'R', long)]
84        role: Vec<String>,
85    },
86    /// Lock an asset, preventing any actions to be performed on it.
87    Lock {
88        /// The asset to lock.
89        asset: Pubkey,
90
91        /// Path to the signer keypair file. Defaults to the config keypair.
92        signer_keypair_path: Option<PathBuf>,
93    },
94    /// Revoke a delegate from an asset.
95    Revoke {
96        /// The asset to revoke the delegate from.
97        asset: Pubkey,
98
99        /// The roles to revoke: "burn", "lock", "transfer".
100        /// Specify each one separately: --role burn --role lock --role transfer
101        #[arg(short = 'R', long)]
102        role: Vec<String>,
103
104        /// Revoke all roles from the delegate and clear it.
105        #[arg(long)]
106        all: bool,
107    },
108    /// Transfer an asset to a new owner.
109    Transfer {
110        /// The asset to transfer.
111        asset: Pubkey,
112
113        /// The recipient of the asset.
114        recipient: Pubkey,
115    },
116    /// Unlock an asset, allowing actions to be performed on it.
117    Unlock {
118        /// The asset to unlock.
119        asset: Pubkey,
120
121        /// Path to the signer keypair file. Defaults to the config keypair.
122        signer_keypair_path: Option<PathBuf>,
123    },
124}