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
use clap::Parser;
mod block;
mod commands;
mod domain;
mod export;
mod import;
mod logo;
mod publish;
mod serve;
mod util;
use commands::*;
use util::*;
fn main() {
let cli = Cli::parse();
match &cli.command {
cmd => match cmd {
Commands::Domain(domain_args) => {
// Generate a new subspace keypair and pressent it to the user
domain::generate_domain(domain_args);
}
Commands::Publish(publish_args) => {
// Verify a domain keypair, then recurse through the given filesystem location,
// writing entries to that domain for any files encountered.
//
// Skip files matching globs in ".nopublish" files, and the ".nopublish" files themselves.
smol::block_on(async {
match publish::publish(publish_args).await {
Ok(_) => yay("publishing complete!").await,
Err(err) => oh_no(&format!("{}", err)).await,
}
})
}
Commands::Block(block_args) => {
// Forget the given subspace ID from persistent storage.
// And add it to a blocklist, which for now could maybe just be a line delimited text file.
smol::block_on(async {
match block::block(block_args).await {
Ok(_) => yay("domain blocked").await,
Err(err) => oh_no(&format! {"{}", err}).await,
}
})
}
Commands::Import(import_args) => {
// Import the contents of a drop into the persistent store.
smol::block_on(async {
match import::import_sneak(import_args).await {
Ok(_) => {
yay(&format!(
"successfully imported from {}",
import_args.src.to_string_lossy()
))
.await
}
Err(err) => oh_no(&format!("{}", err)).await,
}
})
}
Commands::Export(export_args) => {
// Export the contents of the persistent store into a willow drop.
smol::block_on(async {
match export::export_sneak(export_args).await {
Ok(dest) => {
yay(&format!("sneak exported to {}", dest.to_string_lossy())).await
}
Err(err) => oh_no(&format!("{}", err)).await,
}
})
}
&Commands::Serve => {
smol::block_on(async {
match serve::start_server().await {
Ok(()) => (), // I don't think we have anything interesting to say when the server shuts down?
Err(err) => oh_no(&format!("{}", err)).await,
}
});
}
},
}
}