Skip to content

Commit

Permalink
refactor: (args), devided code into multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
pwnwriter committed Jun 27, 2023
1 parent 1982893 commit 0ce2623
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 32 deletions.
33 changes: 33 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use clap::Parser;

#[derive(Parser)]
#[command(author, version, about, long_about = "None")]
pub struct Cli {
#[arg(short, long)]
/// Website URL/filename of file containing URLs
pub url: String,

#[arg(short, long, default_value = "hxnshots")]
/// Output directory to save screenshots
pub outdir: String,

#[arg(short, long, default_value = "4")]
/// Maximum number of parallel tabs
pub tabs: Option<usize>,

#[arg(short, long, default_value = "/usr/bin/google-chrome")]
/// Browser binary path
pub binary_path: String,

#[arg(short = 'x', long, default_value = "1440")]
/// Width of the website // URL
pub width: Option<u32>,

#[arg(short = 'y', long, default_value = "900")]
/// Height of the website // URL
pub height: Option<u32>,

#[arg(short, long)]
/// Silent mode (suppress all console output)
pub silent: bool,
}
35 changes: 3 additions & 32 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod args;
use args::*;
mod colors;
use colors::*;
mod ascii;
Expand Down Expand Up @@ -26,37 +28,6 @@ use clap::Parser;

use columns::Columns;

#[derive(Parser)]
#[command(author, version, about, long_about = "None")]
struct Cli {
#[arg(short, long)]
/// Website URL/filename of file containing URLs
url: String,

#[arg(short, long, default_value = "hxnshots")]
/// Output directory to save screenshots
outdir: String,

#[arg(short, long, default_value = "4")]
/// Maximum number of parallel tabs
tabs: Option<usize>,

#[arg(short, long, default_value = "/usr/bin/google-chrome")]
/// Browser binary path
binary_path: String,

#[arg(short = 'x', long, default_value = "1440")]
/// Width of the website // URL
width: Option<u32>,

#[arg(short = 'y', long, default_value = "900")]
/// Height of the website // URL
height: Option<u32>,

#[arg(short, long)]
/// Silent mode (suppress all console output)
silent: bool,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
println!("{CYAN}{}{RESET}", HXN);
Expand Down Expand Up @@ -168,7 +139,7 @@ async fn run(
handle
.await?
.expect("Something went wrong while waiting for taking screenshot and saving to file");
}
}

exit_on_error();

Expand Down

0 comments on commit 0ce2623

Please sign in to comment.