Create the arguments moudule 💙🦀

This commit is contained in:
Anas Elgarhy 2022-10-03 16:04:38 +02:00
parent 9d6a866c63
commit f063b186c2
10 changed files with 102 additions and 0 deletions

8
.idea/.gitignore vendored Normal file
View file

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

12
.idea/aarty.iml Normal file
View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

7
.idea/discord.xml Normal file
View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DiscordProjectSettings">
<option name="show" value="PROJECT_FILES" />
<option name="description" value="" />
</component>
</project>

6
.idea/jpa-buddy.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JpaBuddyIdeaProjectConfig">
<option name="renamerInitialized" value="true" />
</component>
</project>

6
.idea/misc.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectType">
<option name="id" value="jpab" />
</component>
</project>

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/aarty.iml" filepath="$PROJECT_DIR$/.idea/aarty.iml" />
</modules>
</component>
</project>

6
.idea/vcs.xml Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View file

@ -2,6 +2,7 @@
name = "aarty"
version = "0.1.0"
edition = "2021"
authors = ["Anas Elgarhy <anas.elgarhy.dev@gmail.com>"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

41
src/args.rs Normal file
View file

@ -0,0 +1,41 @@
pub mod args {
use clap::{Parser, arg, ValueEnum, ColorChoice};
#[derive(Parser)]
#[command(author, version, about, long_about=None, color=ColorChoice::Always)]
pub struct Arguments {
/// The art mode to use
#[arg(short, long, default_value="normal-ascii")]
pub mode: Mode,
#[arg(long, default_value="stdout", alias="mo")]
pub output_method: OutputMethod,
/// The image to convert to ASCII art
pub image: String,
/// The output file to write to (if output_method is file)
#[arg(short, long, default_value=Some("ascii_image.txt"))]
pub output: Option<String>,
}
#[derive(Copy, Clone, ValueEnum, Debug, PartialOrd, Eq, PartialEq)]
pub enum Mode {
/// Normal ASCII art
#[clap(alias = "n")]
NormalAscii,
/// Colored ASCII art, the colors are based on the terminal colors
#[clap(alias = "c")]
COLORED,
}
#[derive(Copy, Clone, ValueEnum, Debug, PartialOrd, Eq, PartialEq)]
pub enum OutputMethod {
/// Save the ascii art to a file
#[clap(alias = "f")]
File,
#[clap(alias = "c")]
/// Copy the ascii art to the clipboard
Clipboard,
/// Print the ascii art to the terminal
#[clap(alias = "s")]
Stdout,
}
}

View file

@ -1,3 +1,10 @@
use clap::{Parser};
mod args;
use crate::args::args::Arguments;
fn main() {
let arguments = Arguments::parse();
println!("Hello, world!");
}