-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement trust subcommand and committing home
- Loading branch information
1 parent
540dca8
commit 0172406
Showing
12 changed files
with
181 additions
and
56 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use std::path::Path; | ||
|
||
use tokio::fs::{read_to_string, write}; | ||
|
||
use super::{StorageResult, TrustStorage}; | ||
|
||
const FILE_PATH_TRUST: &str = "trusted.txt"; | ||
|
||
impl TrustStorage { | ||
pub(super) async fn load(home_path: impl AsRef<Path>) -> StorageResult<Self> { | ||
let path = home_path.as_ref().join(FILE_PATH_TRUST); | ||
match read_to_string(&path).await { | ||
Err(e) if e.kind() == std::io::ErrorKind::NotFound => Ok(TrustStorage::new()), | ||
Err(e) => Err(e.into()), | ||
Ok(s) => Ok(TrustStorage::from_str(s)), | ||
} | ||
} | ||
|
||
pub(super) async fn save(&self, home_path: impl AsRef<Path>) -> StorageResult<()> { | ||
let path = home_path.as_ref().join(FILE_PATH_TRUST); | ||
Ok(write(path, self.to_string()).await?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod home; | ||
mod load_and_save; | ||
mod result; | ||
mod trust; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
|
||
use aftman::storage::Home; | ||
|
||
/// Lists all existing tools managed by Aftman. | ||
#[derive(Debug, Parser)] | ||
pub struct ListSubcommand {} | ||
|
||
impl ListSubcommand { | ||
pub async fn run(&self) -> Result<()> { | ||
pub async fn run(&self, _home: &Home) -> Result<()> { | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.