-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.rs
More file actions
114 lines (96 loc) · 3.05 KB
/
cli.rs
File metadata and controls
114 lines (96 loc) · 3.05 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
use serde::{Serialize, Deserialize};
use clap::{Parser, Subcommand, ValueEnum};
#[derive(Debug, Parser)]
#[command(name = "trust")]
#[clap(author, version, about = "TrustGraph CLI", long_about = None)]
pub struct Cli {
// #[arg(value_enum)]
// pub config: Option<ConfigSettings>,
#[command(subcommand)]
pub command: Option<Commands>,
}
// #[derive(Debug, Args)]
// enum ConfigSettings {
// }
#[derive(Debug, Subcommand)]
pub enum Commands {
#[command(arg_required_else_help = true)]
Claim {
/// DID or URL of claim target
#[arg(short ='t', long, required = true)]
target: String,
/// DID or URL of claim creator
#[arg(short, long, required = true)]
creator: Option<String>,
/// Rating tags (at least 1 tag is required)
#[arg(long, required = true, num_args(1..2))]
tags: Option<String>,
/// Rating description
#[arg(short, long)]
description: Option<String>,
/// Extra data (can be used multiple times)
// #[arg(short, long, action = clap::ArgAction::Count)]
// extra: Option<String>,
/// Rating weight in the range 0..1
#[arg(short, long)]
value: Option<f32>,
/// Signing algorithm
// #[arg(short, long, default_value = Some(String::from("EcdsaKoblitzSignature2016")))] // TODO: fix formatting error
// algorithm: Option<String>,
/// Private key
#[arg(short, long, required = true)]
private_key: Option<String>,
/// OpenTrustClaim | Reputon | TrustAtom | TrustClaim
#[arg(long, value_enum)]
target_format: Option<TargetFormat>,
/// Stdout | File | IPFS
#[arg(short, long, value_enum)]
write: Option<WriteTo>,
},
#[command(arg_required_else_help = true)]
Graph {
#[command(subcommand)]
subcommand: Option<GraphCommands>,
/// Perspective (identity) through which trust network is seen
#[arg(short, long)]
perspective: String,
/// DID or URL of claim creator
#[arg(short, long)]
creator: Option<String>,
/// DID or URL of claim target
#[arg(short = 't', long)]
target: Option<String>,
/// Filter by tags
#[arg(long, num_args(1..2))]
tags: Option<String>,
/// Crawls trust ratings to specified depth
#[arg(short, long)]
depth: Option<i8>,
/// Min trust rating 0..1
#[arg(long)]
min_value: Option<f32>,
/// Max trust rating 0..1
#[arg(long)]
max_value: Option<f32>,
},
}
#[derive(Debug, Clone, Subcommand, ValueEnum)]
pub enum GraphCommands {
/// Summarize claims / build analysis
Summarize,
/// Trust level relative to depth, eg: [1, 0.5 0.33]
Falloff,
}
#[derive(Debug, Clone, Serialize, Deserialize, ValueEnum)]
pub enum TargetFormat {
OpenTrustClaim,
Reputon,
TrustAtom,
TrustClaim,
}
#[derive(Debug, Clone, Serialize, Deserialize, ValueEnum)]
pub enum WriteTo {
Stdout,
File,
Ipfs,
}