-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
Showing
13 changed files
with
198 additions
and
17 deletions.
There are no files selected for viewing
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
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,27 @@ | ||
use anyhow::Result; | ||
use clap::{Args, Subcommand}; | ||
|
||
/// Manage the cache | ||
#[derive(Args, Debug)] | ||
#[command(hide = env!("PYAPP_EXPOSE_CACHE") == "0")] | ||
pub struct Cli { | ||
#[command(subcommand)] | ||
command: Commands, | ||
} | ||
|
||
#[derive(Subcommand, Debug)] | ||
enum Commands { | ||
Dist(super::dist::Cli), | ||
Pip(super::pip::Cli), | ||
Uv(super::uv::Cli), | ||
} | ||
|
||
impl Cli { | ||
pub fn exec(self) -> Result<()> { | ||
match self.command { | ||
Commands::Dist(cli) => cli.exec(), | ||
Commands::Pip(cli) => cli.exec(), | ||
Commands::Uv(cli) => cli.exec(), | ||
} | ||
} | ||
} |
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,35 @@ | ||
use std::fs; | ||
|
||
use anyhow::Result; | ||
use clap::Args; | ||
|
||
use crate::app; | ||
|
||
/// Manage the distribution cache | ||
#[derive(Args, Debug)] | ||
#[command()] | ||
pub struct Cli { | ||
#[arg(short, long)] | ||
remove: bool, | ||
} | ||
|
||
impl Cli { | ||
pub fn exec(self) -> Result<()> { | ||
let distributions_dir = app::distributions_cache(); | ||
let distribution_file = distributions_dir.join(app::distribution_id()); | ||
if !distribution_file.exists() { | ||
if self.remove { | ||
println!("Does not exist"); | ||
} | ||
return Ok(()); | ||
} | ||
|
||
if self.remove { | ||
fs::remove_file(distribution_file)?; | ||
} else { | ||
println!("{}", distribution_file.display()); | ||
} | ||
|
||
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,4 @@ | ||
pub mod cli; | ||
pub mod dist; | ||
pub mod pip; | ||
pub mod uv; |
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,39 @@ | ||
use std::fs; | ||
|
||
use anyhow::Result; | ||
use clap::Args; | ||
|
||
use crate::app; | ||
|
||
/// Manage the external pip cache | ||
#[derive(Args, Debug)] | ||
#[command()] | ||
pub struct Cli { | ||
#[arg(short, long)] | ||
remove: bool, | ||
} | ||
|
||
impl Cli { | ||
pub fn exec(self) -> Result<()> { | ||
if !app::pip_external() { | ||
println!("External pip not enabled"); | ||
return Ok(()); | ||
} | ||
|
||
let external_pip = app::external_pip_zipapp(); | ||
if !external_pip.exists() { | ||
if self.remove { | ||
println!("Does not exist"); | ||
} | ||
return Ok(()); | ||
} | ||
|
||
if self.remove { | ||
fs::remove_file(external_pip)?; | ||
} else { | ||
println!("{}", external_pip.display()); | ||
} | ||
|
||
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,39 @@ | ||
use std::fs; | ||
|
||
use anyhow::Result; | ||
use clap::Args; | ||
|
||
use crate::app; | ||
|
||
/// Manage the UV cache | ||
#[derive(Args, Debug)] | ||
#[command()] | ||
pub struct Cli { | ||
#[arg(short, long)] | ||
remove: bool, | ||
} | ||
|
||
impl Cli { | ||
pub fn exec(self) -> Result<()> { | ||
if !app::uv_enabled() { | ||
println!("UV is not enabled"); | ||
return Ok(()); | ||
} | ||
|
||
let managed_uv = app::managed_uv(); | ||
if !managed_uv.exists() { | ||
if self.remove { | ||
println!("Does not exist"); | ||
} | ||
return Ok(()); | ||
} | ||
|
||
if self.remove { | ||
fs::remove_file(managed_uv)?; | ||
} else { | ||
println!("{}", managed_uv.display()); | ||
} | ||
|
||
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod cache; | ||
pub mod cli; | ||
pub mod metadata; | ||
pub mod pip; | ||
|
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