diff options
author | fxqnlr <[email protected]> | 2024-09-09 23:03:49 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-09 23:03:49 +0200 |
commit | 553bbac36bdc483135a7053ca64507e01397e5e1 (patch) | |
tree | 494dad0623628df4f1b86b93da51edf60795a901 /src/main.rs | |
parent | d396881816cd256cb12d03deebea445cba99ea85 (diff) | |
download | arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar arbs-553bbac36bdc483135a7053ca64507e01397e5e1.tar.gz arbs-553bbac36bdc483135a7053ca64507e01397e5e1.zip |
add package manager recognition
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs index 1284e0c..7393af9 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -1,10 +1,13 @@ | |||
1 | use backup::Backup; | 1 | use backup::Backup; |
2 | use clap::Parser; | ||
3 | use cli::Subcommands; | ||
2 | use config::Config; | 4 | use config::Config; |
3 | use packages::{pacman::Pacman, PackageManager}; | 5 | use error::Error; |
4 | use tracing::{debug, info, level_filters::LevelFilter}; | 6 | use tracing::{debug, level_filters::LevelFilter}; |
5 | use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; | 7 | use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; |
6 | 8 | ||
7 | mod backup; | 9 | mod backup; |
10 | mod cli; | ||
8 | mod config; | 11 | mod config; |
9 | mod error; | 12 | mod error; |
10 | mod packages; | 13 | mod packages; |
@@ -13,7 +16,7 @@ mod pathinfo; | |||
13 | fn main() -> color_eyre::Result<()> { | 16 | fn main() -> color_eyre::Result<()> { |
14 | color_eyre::install()?; | 17 | color_eyre::install()?; |
15 | 18 | ||
16 | let file_appender = tracing_appender::rolling::never("./", "arps.log"); | 19 | let file_appender = tracing_appender::rolling::never("./", "arbs.log"); |
17 | let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); | 20 | let (non_blocking, _guard) = tracing_appender::non_blocking(file_appender); |
18 | 21 | ||
19 | tracing_subscriber::registry() | 22 | tracing_subscriber::registry() |
@@ -33,19 +36,24 @@ fn main() -> color_eyre::Result<()> { | |||
33 | .init(); | 36 | .init(); |
34 | debug!("logging initialized"); | 37 | debug!("logging initialized"); |
35 | 38 | ||
36 | let mut cfg = Config::load()?; | 39 | let cli = cli::Cli::parse(); |
37 | cfg.user.push("fx".to_string()); | 40 | |
38 | cfg.directories.push("~/.config/nvim".to_string()); | 41 | let config = Config::load(cli.config)?; |
39 | cfg.root = "./backup".to_string(); | 42 | |
40 | 43 | match cli.subcommand { | |
41 | let pacman = Pacman; | 44 | Subcommands::GenerateConfig => Config::generate()?, |
42 | let pkgs = pacman.get_installed()?; | 45 | Subcommands::Save { package_manager } => { |
43 | let backup = Backup::create(&cfg, pkgs); | 46 | let backup = Backup::create(&config, package_manager)?; |
44 | // info!(?backup); | 47 | backup.save(&config)?; |
45 | // pacman.install(vec![Package { | 48 | } |
46 | // id: "lapce".to_string(), | 49 | Subcommands::Restore => { |
47 | // version: "0.4.2-1".to_string(), | 50 | let Some(last_backup) = Backup::get_last(&config)? else { |
48 | // explicit: true, | 51 | return Err(Error::BackupNotFound)?; |
49 | // }])?; | 52 | }; |
53 | |||
54 | last_backup.packages.install()?; | ||
55 | last_backup.restore(); | ||
56 | } | ||
57 | }; | ||
50 | Ok(()) | 58 | Ok(()) |
51 | } | 59 | } |