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
|
use anyhow::{Context, Result};
use clap;
use crate::{
cli::{extract_signer_cli_arguments, Cli},
client::{Client, Connect},
git::Repo,
login::fresh::fresh_login_or_signup,
};
#[derive(clap::Args)]
pub struct SubCommandArgs {
/// login to the local git repository only
#[arg(long, action)]
local: bool,
/// don't fetch user metadata and relay list from relays
#[arg(long, action)]
offline: bool,
}
pub async fn launch(args: &Cli, command_args: &SubCommandArgs) -> Result<()> {
// TODO show existing login on record, prompt to logout
let client = if command_args.offline {
None
} else {
Some(Client::default())
};
let git_repo_result = Repo::discover().context("cannot find a git repository");
let git_repo_option = {
match git_repo_result {
Ok(git_repo) => Some(git_repo),
Err(_) => None,
}
};
fresh_login_or_signup(
&git_repo_option.as_ref(),
client.as_ref(),
extract_signer_cli_arguments(args)?,
command_args.local,
)
.await?;
// If not offline, disconnect the client
if let Some(client) = client {
client.disconnect().await?;
}
Ok(())
}
|