-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
30d505d
commit 1478548
Showing
12 changed files
with
156 additions
and
32 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
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,34 @@ | ||
use std::fs; | ||
|
||
use super::super::config::locator; | ||
use crate::commands::config::data; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Config(#[from] locator::Error), | ||
#[error(transparent)] | ||
Data(#[from] data::Error), | ||
#[error(transparent)] | ||
Io(#[from] std::io::Error), | ||
} | ||
|
||
#[derive(Debug, clap::Parser, Clone)] | ||
#[group(skip)] | ||
pub struct Cmd { | ||
/// Actions only | ||
#[arg(long, short = 'a')] | ||
pub actions: bool, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self) -> Result<(), Error> { | ||
let dir = if self.actions { | ||
data::actions_dir()? | ||
} else { | ||
data::project_dir()?.data_dir().to_path_buf() | ||
}; | ||
fs::remove_dir_all(dir)?; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use super::super::config::locator; | ||
use crate::commands::config::data; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Config(#[from] locator::Error), | ||
#[error(transparent)] | ||
Data(#[from] data::Error), | ||
} | ||
|
||
#[derive(Debug, clap::Parser, Clone)] | ||
#[group(skip)] | ||
pub struct Cmd {} | ||
|
||
impl Cmd { | ||
pub fn run(&self) -> Result<(), Error> { | ||
let binding = data::project_dir()?; | ||
let dir = binding.data_dir(); | ||
println!("{}", dir.to_string_lossy()); | ||
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
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,42 @@ | ||
use clap::Parser; | ||
|
||
pub mod clean; | ||
pub mod info; | ||
pub mod ls; | ||
pub mod read; | ||
|
||
#[derive(Debug, Parser)] | ||
pub enum Cmd { | ||
/// List cached actions (transactions, simulations) | ||
Ls(ls::Cmd), | ||
/// Show location of cache | ||
Info(info::Cmd), | ||
/// Delete all cached actions | ||
Clean(clean::Cmd), | ||
/// Read cached action | ||
Read(read::Cmd), | ||
} | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Info(#[from] info::Error), | ||
#[error(transparent)] | ||
Ls(#[from] ls::Error), | ||
#[error(transparent)] | ||
Clean(#[from] clean::Error), | ||
#[error(transparent)] | ||
Read(#[from] read::Error), | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self) -> Result<(), Error> { | ||
match self { | ||
Cmd::Ls(cmd) => cmd.run()?, | ||
Cmd::Info(cmd) => cmd.run()?, | ||
Cmd::Clean(cmd) => cmd.run()?, | ||
Cmd::Read(cmd) => cmd.run()?, | ||
}; | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::fs; | ||
|
||
use super::super::config::locator; | ||
use crate::commands::config::data; | ||
|
||
#[derive(thiserror::Error, Debug)] | ||
pub enum Error { | ||
#[error(transparent)] | ||
Config(#[from] locator::Error), | ||
#[error(transparent)] | ||
Data(#[from] data::Error), | ||
#[error("failed to find cache entry {0}")] | ||
NotFound(String), | ||
} | ||
|
||
#[derive(Debug, clap::Parser, Clone)] | ||
#[group(skip)] | ||
pub struct Cmd { | ||
/// ULID of the cache entry | ||
#[arg(long, visible_alias = "id")] | ||
ulid: String, | ||
} | ||
|
||
impl Cmd { | ||
pub fn run(&self) -> Result<(), Error> { | ||
let dir = data::actions_dir()?; | ||
fs::read_to_string(dir.join(&self.ulid).with_extension(".json")) | ||
.map_err(|_| Error::NotFound(self.ulid.clone()))?; | ||
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
This file was deleted.
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