Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to skip emojis step #9

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ pub struct GitConfig {
#[clap(long, short)]
pub skip_preview: bool,

/// Confirm before to run git commit
#[clap(long, short)]
pub skip_emojis: bool,

/// Command to run after generate commit message
#[clap(long, short)]
#[merge(strategy = swap_option)]
Expand Down
220 changes: 134 additions & 86 deletions src/gen/emojis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,100 +7,148 @@ use serde::Deserialize;

#[derive(Deserialize, Clone)]
pub struct Emoji {
pub emoji: &'static str,
pub description: &'static str,
pub name: &'static str,
pub emoji: &'static str,
pub description: &'static str,
pub name: &'static str,
}

impl Emoji {
const fn new(emoji: &'static str, name: &'static str, description: &'static str) -> Self {
Self {
emoji,
name,
description,
const fn new(emoji: &'static str, name: &'static str, description: &'static str) -> Self {
Self {
emoji,
name,
description,
}
}
}
}

impl std::fmt::Display for Emoji {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let name = format!("({})", self.name).bright_blue();
write!(f, "{} | {} {}", self.emoji, self.description, name)
}
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let name = format!("({})", self.name).bright_blue();
write!(f, "{} | {} {}", self.emoji, self.description, name)
}
}

pub const EMOJIS: [Emoji; 73] = [
Emoji::new("🎨", "art", "Improve structure / format of the code."),
Emoji::new("⚡️", "zap", "Improve performance."),
Emoji::new("🔥", "fire", "Remove code or files."),
Emoji::new("🐛", "bug", "Fix a bug."),
Emoji::new("🚑️", "ambulance", "Critical hotfix."),
Emoji::new("✨", "sparkles", "Introduce new features."),
Emoji::new("📝", "memo", "Add or update documentation."),
Emoji::new("🚀", "rocket", "Deploy stuff."),
Emoji::new("💄", "lipstick", "Add or update the UI and style files."),
Emoji::new("🎉", "tada", "Begin a project."),
Emoji::new("✅", "white-check-mark", "Add, update, or pass tests."),
Emoji::new("🔒️", "lock", "Fix security or privacy issues."),
Emoji::new("🔐", "closed-lock-with-key", "Add or update secrets."),
Emoji::new("🔖", "bookmark", "Release / Version tags."),
Emoji::new("🚨", "rotating-light", "Fix compiler / linter warnings."),
Emoji::new("🚧", "construction", "Work in progress."),
Emoji::new("💚", "green-heart", "Fix CI Build."),
Emoji::new("⬇️", "arrow-down", "Downgrade dependencies."),
Emoji::new("⬆️", "arrow-up", "Upgrade dependencies."),
Emoji::new("📌", "pushpin", "Pin dependencies to specific versions."),
Emoji::new("👷", "construction-worker", "Add or update CI build system."),
Emoji::new("📈", "chart-with-upwards-trend", "Add or update analytics or track code."),
Emoji::new("♻️", "recycle", "Refactor code."),
Emoji::new("➕", "heavy-plus-sign", "Add a dependency."),
Emoji::new("➖", "heavy-minus-sign", "Remove a dependency."),
Emoji::new("🔧", "wrench", "Add or update configuration files."),
Emoji::new("🔨", "hammer", "Add or update development scripts."),
Emoji::new("🌐", "globe-with-meridians", "Internationalization and localization."),
Emoji::new("✏️", "pencil2", "Fix typos."),
Emoji::new("💩", "poop", "Write bad code that needs to be improved."),
Emoji::new("⏪️", "rewind", "Revert changes."),
Emoji::new("🔀", "twisted-rightwards-arrows", "Merge branches."),
Emoji::new("📦️", "package", "Add or update compiled files or packages."),
Emoji::new("👽️", "alien", "Update code due to external API changes."),
Emoji::new("🚚", "truck", "Move or rename resources (e.g.: files, paths, routes)."),
Emoji::new("📄", "page-facing-up", "Add or update license."),
Emoji::new("💥", "boom", "Introduce breaking changes."),
Emoji::new("🍱", "bento", "Add or update assets."),
Emoji::new("♿️", "wheelchair", "Improve accessibility."),
Emoji::new("💡", "bulb", "Add or update comments in source code."),
Emoji::new("🍻", "beers", "Write code drunkenly."),
Emoji::new("💬", "speech-balloon", "Add or update text and literals."),
Emoji::new("🗃️", "card-file-box", "Perform database related changes."),
Emoji::new("🔊", "loud-sound", "Add or update logs."),
Emoji::new("🔇", "mute", "Remove logs."),
Emoji::new("👥", "busts-in-silhouette", "Add or update contributor(s)."),
Emoji::new("🚸", "children-crossing", "Improve user experience / usability."),
Emoji::new("🏗️", "building-construction", "Make architectural changes."),
Emoji::new("📱", "iphone", "Work on responsive design."),
Emoji::new("🤡", "clown-face", "Mock things."),
Emoji::new("🥚", "egg", "Add or update an easter egg."),
Emoji::new("🙈", "see-no-evil", "Add or update a .gitignore file."),
Emoji::new("📸", "camera-flash", "Add or update snapshots."),
Emoji::new("⚗️", "alembic", "Perform experiments."),
Emoji::new("🔍️", "mag", "Improve SEO."),
Emoji::new("🏷️", "label", "Add or update types."),
Emoji::new("🌱", "seedling", "Add or update seed files."),
Emoji::new("🚩", "triangular-flag-on-post", "Add, update, or remove feature flags."),
Emoji::new("🥅", "goal-net", "Catch errors."),
Emoji::new("💫", "dizzy", "Add or update animations and transitions."),
Emoji::new("🗑️", "wastebasket", "Deprecate code that needs to be cleaned up."),
Emoji::new("🛂", "passport-control", "Work on code related to authorization, roles and permissions."),
Emoji::new("🩹", "adhesive-bandage", "Simple fix for a non-critical issue."),
Emoji::new("🧐", "monocle-face", "Data exploration/inspection."),
Emoji::new("⚰️", "coffin", "Remove dead code."),
Emoji::new("🧪", "test-tube", "Add a failing test."),
Emoji::new("👔", "necktie", "Add or update business logic."),
Emoji::new("🩺", "stethoscope", "Add or update healthcheck."),
Emoji::new("🧱", "bricks", "Infrastructure related changes."),
Emoji::new("🧑‍💻", "technologist", "Improve developer experience."),
Emoji::new("💸", "money-with-wings", "Add sponsorships or money related infrastructure."),
Emoji::new("🧵", "thread", "Add or update code related to multithreading or concurrency."),
Emoji::new("🦺", "safety-vest", "Add or update code related to validation."),
Emoji::new("🎨", "art", "Improve structure / format of the code."),
Emoji::new("⚡️", "zap", "Improve performance."),
Emoji::new("🔥", "fire", "Remove code or files."),
Emoji::new("🐛", "bug", "Fix a bug."),
Emoji::new("🚑️", "ambulance", "Critical hotfix."),
Emoji::new("✨", "sparkles", "Introduce new features."),
Emoji::new("📝", "memo", "Add or update documentation."),
Emoji::new("🚀", "rocket", "Deploy stuff."),
Emoji::new("💄", "lipstick", "Add or update the UI and style files."),
Emoji::new("🎉", "tada", "Begin a project."),
Emoji::new("✅", "white-check-mark", "Add, update, or pass tests."),
Emoji::new("🔒️", "lock", "Fix security or privacy issues."),
Emoji::new("🔐", "closed-lock-with-key", "Add or update secrets."),
Emoji::new("🔖", "bookmark", "Release / Version tags."),
Emoji::new("🚨", "rotating-light", "Fix compiler / linter warnings."),
Emoji::new("🚧", "construction", "Work in progress."),
Emoji::new("💚", "green-heart", "Fix CI Build."),
Emoji::new("⬇️", "arrow-down", "Downgrade dependencies."),
Emoji::new("⬆️", "arrow-up", "Upgrade dependencies."),
Emoji::new("📌", "pushpin", "Pin dependencies to specific versions."),
Emoji::new(
"👷",
"construction-worker",
"Add or update CI build system.",
),
Emoji::new(
"📈",
"chart-with-upwards-trend",
"Add or update analytics or track code.",
),
Emoji::new("♻️", "recycle", "Refactor code."),
Emoji::new("➕", "heavy-plus-sign", "Add a dependency."),
Emoji::new("➖", "heavy-minus-sign", "Remove a dependency."),
Emoji::new("🔧", "wrench", "Add or update configuration files."),
Emoji::new("🔨", "hammer", "Add or update development scripts."),
Emoji::new(
"🌐",
"globe-with-meridians",
"Internationalization and localization.",
),
Emoji::new("✏️", "pencil2", "Fix typos."),
Emoji::new("💩", "poop", "Write bad code that needs to be improved."),
Emoji::new("⏪️", "rewind", "Revert changes."),
Emoji::new("🔀", "twisted-rightwards-arrows", "Merge branches."),
Emoji::new("📦️", "package", "Add or update compiled files or packages."),
Emoji::new("👽️", "alien", "Update code due to external API changes."),
Emoji::new(
"🚚",
"truck",
"Move or rename resources (e.g.: files, paths, routes).",
),
Emoji::new("📄", "page-facing-up", "Add or update license."),
Emoji::new("💥", "boom", "Introduce breaking changes."),
Emoji::new("🍱", "bento", "Add or update assets."),
Emoji::new("♿️", "wheelchair", "Improve accessibility."),
Emoji::new("💡", "bulb", "Add or update comments in source code."),
Emoji::new("🍻", "beers", "Write code drunkenly."),
Emoji::new("💬", "speech-balloon", "Add or update text and literals."),
Emoji::new("🗃️", "card-file-box", "Perform database related changes."),
Emoji::new("🔊", "loud-sound", "Add or update logs."),
Emoji::new("🔇", "mute", "Remove logs."),
Emoji::new("👥", "busts-in-silhouette", "Add or update contributor(s)."),
Emoji::new(
"🚸",
"children-crossing",
"Improve user experience / usability.",
),
Emoji::new("🏗️", "building-construction", "Make architectural changes."),
Emoji::new("📱", "iphone", "Work on responsive design."),
Emoji::new("🤡", "clown-face", "Mock things."),
Emoji::new("🥚", "egg", "Add or update an easter egg."),
Emoji::new("🙈", "see-no-evil", "Add or update a .gitignore file."),
Emoji::new("📸", "camera-flash", "Add or update snapshots."),
Emoji::new("⚗️", "alembic", "Perform experiments."),
Emoji::new("🔍️", "mag", "Improve SEO."),
Emoji::new("🏷️", "label", "Add or update types."),
Emoji::new("🌱", "seedling", "Add or update seed files."),
Emoji::new(
"🚩",
"triangular-flag-on-post",
"Add, update, or remove feature flags.",
),
Emoji::new("🥅", "goal-net", "Catch errors."),
Emoji::new("💫", "dizzy", "Add or update animations and transitions."),
Emoji::new(
"🗑️",
"wastebasket",
"Deprecate code that needs to be cleaned up.",
),
Emoji::new(
"🛂",
"passport-control",
"Work on code related to authorization, roles and permissions.",
),
Emoji::new(
"🩹",
"adhesive-bandage",
"Simple fix for a non-critical issue.",
),
Emoji::new("🧐", "monocle-face", "Data exploration/inspection."),
Emoji::new("⚰️", "coffin", "Remove dead code."),
Emoji::new("🧪", "test-tube", "Add a failing test."),
Emoji::new("👔", "necktie", "Add or update business logic."),
Emoji::new("🩺", "stethoscope", "Add or update healthcheck."),
Emoji::new("🧱", "bricks", "Infrastructure related changes."),
Emoji::new("🧑‍💻", "technologist", "Improve developer experience."),
Emoji::new(
"💸",
"money-with-wings",
"Add sponsorships or money related infrastructure.",
),
Emoji::new(
"🧵",
"thread",
"Add or update code related to multithreading or concurrency.",
),
Emoji::new(
"🦺",
"safety-vest",
"Add or update code related to validation.",
),
];
11 changes: 10 additions & 1 deletion src/tui/steps/emoji.rs
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pretty clear!, looks good.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ use crate::tui::{helpers::format_emojis, Step, StepError, StepResult};
pub struct _Step;

impl Step for _Step {
fn run(&self, state: &mut crate::tui::State, _: &mut SimpleCommitsConfig) -> StepResult {
fn run(&self, state: &mut crate::tui::State, config: &mut SimpleCommitsConfig) -> StepResult {
// early return if skip_emojis is enabled
if config
.git
.as_ref()
.is_some_and(|git_cfg| git_cfg.skip_emojis)
{
return Ok(());
}

let emoji = Select::new("Select an emoji (optional):", EMOJIS.to_vec())
.with_formatter(&format_emojis)
.prompt_skippable();
Expand Down
Loading