-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcmd_init.rs
45 lines (39 loc) · 1.09 KB
/
cmd_init.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
// Copyright (c) Contributors to the SPK project.
// SPDX-License-Identifier: Apache-2.0
// https://github.com/spkenv/spk
use std::path::PathBuf;
use clap::{Args, Subcommand};
use miette::Result;
use spfs::storage::fs::NoRenderStore;
/// Create an empty filesystem repository
#[derive(Debug, Args)]
pub struct CmdInit {
#[clap(subcommand)]
cmd: InitSubcommand,
}
impl CmdInit {
pub async fn run(&self, config: &spfs::Config) -> Result<i32> {
self.cmd.run(config).await
}
}
#[derive(strum::AsRefStr, Debug, Subcommand)]
#[strum(serialize_all = "lowercase")]
pub enum InitSubcommand {
/// Initialize an empty filesystem repository
///
/// Does nothing when run on an existing repository
Repo {
/// The root of the new repository
path: PathBuf,
},
}
impl InitSubcommand {
pub async fn run(&self, _config: &spfs::Config) -> Result<i32> {
match self {
Self::Repo { path } => {
spfs::storage::fs::MaybeOpenFsRepository::<NoRenderStore>::create(&path).await?;
Ok(0)
}
}
}
}