-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathapp_args.rs
54 lines (45 loc) · 1.64 KB
/
app_args.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::path::PathBuf;
use clap::{Args, Parser, Subcommand};
const DEFAULT_RAIKO_USER_CONFIG_SUBDIR_PATH: &str = ".config/raiko";
#[derive(Debug, Parser)]
pub struct App {
#[command(flatten)]
pub global_opts: GlobalOpts,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// Prove (i.e. sign) a single block and exit.
OneShot(OneShotArgs),
/// Aggregate proofs
Aggregate(OneShotArgs),
/// Bootstrap the application and then exit. The bootstrapping process generates the
/// initial public-private key pair and stores it on the disk in an encrypted
/// format using SGX encryption primitives.
Bootstrap,
/// Check if bootstrap is readable
Check,
}
#[derive(Debug, Args)]
pub struct OneShotArgs {
#[arg(long)]
pub sgx_instance_id: u32,
}
fn get_default_raiko_user_config_path(subdir: &str) -> PathBuf {
let mut home_dir = dirs::home_dir().unwrap();
home_dir.push(DEFAULT_RAIKO_USER_CONFIG_SUBDIR_PATH);
home_dir.push(subdir);
home_dir
}
#[derive(Debug, Args)]
pub struct GlobalOpts {
#[arg(short, long, default_value=get_default_raiko_user_config_path("secrets").into_os_string())]
/// Path to the directory with the encrypted private keys being used to sign the
/// blocks. For more details on the encryption see:
/// https://gramine.readthedocs.io/en/stable/manifest-syntax.html#encrypted-files
pub secrets_dir: PathBuf,
#[arg(short, long, default_value=get_default_raiko_user_config_path("config").into_os_string())]
/// Path to the directory containing Raiko configuration files.
pub config_dir: PathBuf,
}