Skip to content

Commit 984580d

Browse files
committedMar 8, 2023
Partial arg parsing.
1 parent 2183ee2 commit 984580d

File tree

4 files changed

+378
-0
lines changed

4 files changed

+378
-0
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

‎Cargo.lock

+329
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "folderify"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
clap = { version = "4.1.8", features = ["derive"] }

‎src/main.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
use clap::Parser;
2+
3+
/// Generate a native-style macOS folder icon from a mask file.
4+
#[derive(Parser, Debug)]
5+
#[command(author, version, about, long_about = None)]
6+
struct Args {
7+
/// Mask image file. For best results:
8+
/// - Use a .png mask.
9+
/// - Use a solid black design over a transparent background.
10+
/// - Make sure the corner pixels of the mask image are transparent. They are used for empty margins.
11+
/// - Make sure the non-transparent pixels span a height of 384px, using a 16px grid.
12+
/// If the height is 384px and the width is a multiple of 128px, each 64x64 tile will exactly align with 1 pixel at the smallest folder size.
13+
#[clap(verbatim_doc_comment)]
14+
mask: std::path::PathBuf,
15+
/// Target file or folder.
16+
/// If a target is specified, the resulting icon will be applied to the target file/folder.
17+
/// Else, a .iconset folder and .icns file will be created in the same folder as the mask
18+
/// (you can use "Get Info" in Finder to copy the icon from the .icns file).
19+
#[clap(verbatim_doc_comment)]
20+
target: Option<std::path::PathBuf>,
21+
22+
/// Reveal the target (or resulting .icns file) in Finder.
23+
#[clap(short, long)]
24+
reveal: bool,
25+
26+
/// Version of the macOS folder icon, e.g. "10.13".
27+
/// Defaults to the version currently running.
28+
#[clap(long = "macOS", alias = "osx", short_alias = 'x')]
29+
mac_os: Option<String>, // TODO: enum, default?
30+
31+
/// Color scheme: auto (match current system), light, dark.
32+
color_scheme: Option<String>,
33+
}
34+
35+
fn main() {
36+
let args = Args::parse();
37+
38+
println!("Target: {}", args.mask.display());
39+
}

0 commit comments

Comments
 (0)
Please sign in to comment.