Skip to content

Commit

Permalink
Merge branch 'indicatif'
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Mar 12, 2024
2 parents 62979a3 + 2d03755 commit f448287
Show file tree
Hide file tree
Showing 12 changed files with 584 additions and 297 deletions.
337 changes: 192 additions & 145 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "AGPL-3.0"
build = "build-aux/build.rs"

[dependencies]
colored = "2.1"
console = "0.15"
fluent = "0.12"
fluent-fallback = "0.0"
fluent-langneg = "0.13"
Expand Down Expand Up @@ -40,6 +40,10 @@ unic-langid = "0.9"
version = "0.7"
default-features = false

[dependencies.indicatif]
version = "0.17"
features = [ "improved_unicode", "rayon" ]

[dependencies.Inflector]
version = "0.11"
default-features = false
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dist_man_MANS =
nobase_data_DATA = rules/casile.mk $(reverse_lang_key_files)
nobase_dist_data_DATA = rules/rules.mk rules/functions.mk rules/translation.mk rules/utilities.mk $(lang_key_files)
nobase_dist_data_DATA += rules/ebooks.mk rules/mdbook.mk rules/renderings.mk rules/zola.mk
_casile_libs = src/lib.rs src/cli.rs src/config.rs src/i18n.rs
_casile_libs = src/lib.rs src/cli.rs src/config.rs src/i18n.rs src/tui.rs
_casile_modules = src/make/mod.rs src/run/mod.rs src/setup/mod.rs src/status/mod.rs
_casile_assets = assets/en-US/cli.ftl assets/tr-TR/cli.ftl
bin_PROGRAMS = casile
Expand Down
46 changes: 32 additions & 14 deletions assets/en-US/cli.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,29 @@ error-no-path =
welcome =
Welcome to CaSILE { $version }!
outro =
CaSILE run complete
farewell =
CaSILE run completed in { $duration }.
make-header =
Building target(s) using ‘make’
Building target(s) using ‘make’.
make-good =
All target(s) sucessfully made.
make-bad =
Unable to finish making some or all target(s).
make-report-start =
Starting make job for target: { $target }
make-report-end =
make-report-pass =
Finished make job for target: { $target }
make-report-fail =
Failed make job for target: { $target }
make-backlog-start =
Dumping captured output of ‘make’
Dumping captured output of ‘make’:
make-backlog-end =
End dump
Expand Down Expand Up @@ -110,31 +116,37 @@ make-error-unknown =
Make returned unknown error.
run-header =
Running script inside CaSILE environment
Running script inside CaSILE environment.
run-good =
Script successfully run.
run-bad =
Script did not run sucessfully.
setup-header =
Configuring repository for use with CaSILE
Configuring repository for use with CaSILE.
setup-good =
Repository is fully configured for use with CaSILE.
setup-bad =
Repository could not be configured for use with CaSILE.
setup-true =
Yes
setup-false =
No
setup-good =
Everything seems to be ship shape, warm up the presses!
setup-bad =
Hold the presses, something isn’t right, run ‘casile setup’
setup-is-repo =
Is the path a Git repository?
setup-is-deep =
Is the Git a deep clone?
setup-is-not-casile =
Are we not in the CaSILE source repository?
Are we safely outside of the CaSILE source repository?
setup-is-writable =
Can we write to the project base directory?
Expand Down Expand Up @@ -163,6 +175,12 @@ setup-warp-time-file =
status-header =
Scanning project status
status-good =
Everything seems to be ship shape, warm up the presses!
status-bad =
Hold the presses, something isn’t right, run ‘casile setup’
status-is-gha =
Are we running as a GitHub Action?
Expand Down
46 changes: 32 additions & 14 deletions assets/tr-TR/cli.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,51 @@ help-subcommand-run-arguments =
welcome =
CaSILE { $version } sürümüne hoş geldiniz!
outro =
CaSILE çalışması tamamlandı
run-header =
CaSILE ortamı içinde komut dosyası çalıştırılıyor
farewell =
CaSILE çalışması { $duration } içinde tamamlandı.
make-header =
‘make’ aracılığıyla hedef(ler) oluşturuluyor
‘make’ aracılığıyla hedef(ler) oluşturuluyor.
make-good =
Tüm hedef(ler) başarıyla oluşturuldu.
make-bad =
Bazı veya tüm hedef(ler) oluşturulamadı.
make-report-start =
Hedef için işlemeri başlatırılıyor: { $target }
make-report-end =
make-report-pass =
Hedef işlemi başarıyla bittirilmiş: { $target }
make-report-fail =
Hedef işlemi başarsız sonlandırmış: { $target }
run-header =
CaSILE ortamı içinde komut dosyası çalıştırılıyor.
run-good =
Komut dosyası başarıyla çalıştırıldı.
run-bad =
Komut dosyası başarılı bir şekilde çalıştılmadı.
setup-header =
Depoyu CaSILE ile kullanılmak üzere yapılandırılıyor
Depoyu CaSILE ile kullanılmak üzere yapılandırılıyor.
setup-good =
Depoyu CaSILE ile kullanılmak üzere tamamen yapılandırılmıştır.
setup-bad =
Depoyu CaSILE ile kullanılmak üzere yapılandırılamadı.
setup-true =
Evet
setup-false =
Hayır
setup-good =
Her şey yerinde gibi gözüküyor, presleri ısıtın!
setup-bad =
Presleri durdurun, bir eksiklik varmış, 'casile setup' çalıştırın.
setup-is-repo =
Dizin yolu bir Git deposu mudur?
Expand Down Expand Up @@ -74,6 +86,12 @@ setup-warp-time-file =
status-header =
Proje durum inceleniyor
status-good =
Her şey yerinde gibi gözüküyor, presleri ısıtın!
status-bad =
Presleri durdurun, bir eksiklik varmış, 'casile setup' çalıştırın.
status-is-gha =
GitHub Action olarak mı çalıştırıldık?
Expand Down
44 changes: 2 additions & 42 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ extern crate num_cpus;

use crate::config::CONF;

use colored::{ColoredString, Colorize};
use git2::{Oid, Repository, Signature};
use i18n::LocalText;
use regex::Regex;
Expand All @@ -17,6 +16,7 @@ use std::{error, fmt, path, result, str};
pub mod cli;
pub mod config;
pub mod i18n;
pub mod tui;

// Subcommands
pub mod make;
Expand Down Expand Up @@ -86,7 +86,7 @@ pub fn commit(repo: Repository, oid: Oid, msg: &str) -> result::Result<Oid, git2
&[prefix, msg].join(" "),
&tree,
&parents,
)
)
}

pub fn locale_to_language(lang: String) -> String {
Expand All @@ -99,46 +99,6 @@ pub fn locale_to_language(lang: String) -> String {
}
}

/// Output welcome header at start of run before moving on to actual commands
pub fn show_welcome() {
let welcome = LocalText::new("welcome").arg("version", *VERSION);
eprintln!("{} {}", "┏━".cyan(), welcome.fmt().cyan());
}

/// Output welcome header at start of run before moving on to actual commands
pub fn show_outro() {
let outro = LocalText::new("outro");
eprintln!("{} {}", "┗━".cyan(), outro.fmt().cyan());
}

/// Output header before starting work on a subcommand
pub fn show_header(key: &str) {
let text = LocalText::new(key);
eprintln!("{} {}", "┣━".cyan(), text.fmt().yellow());
}

pub fn display_check(key: &str, val: bool) {
if CONF.get_bool("debug").unwrap() || CONF.get_bool("verbose").unwrap() {
eprintln!(
"{} {} {}",
"┠─".cyan(),
LocalText::new(key).fmt(),
fmt_t_f(val)
);
};
}

/// Format a localized string just for true / false status prints
fn fmt_t_f(val: bool) -> ColoredString {
let key = if val { "setup-true" } else { "setup-false" };
let text = LocalText::new(key).fmt();
if val {
text.green()
} else {
text.red()
}
}

#[cfg(unix)]
pub fn bytes2path(b: &[u8]) -> &path::Path {
use std::os::unix::prelude::*;
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use clap::{Args, Command, FromArgMatches as _};

use casile::cli::{Cli, Commands};
use casile::config::CONF;
use casile::tui::*;
use casile::{make, run, setup, status};
use casile::{Result, VERSION};

Expand All @@ -14,14 +15,15 @@ fn main() -> Result<()> {
let matches = cli.get_matches();
let args = Cli::from_arg_matches(&matches).expect("Unable to parse arguments");
CONF.merge_args(&args)?;
casile::show_welcome();
let command_status = CommandStatus::new();
command_status.welcome();
let subcommand = Commands::from_arg_matches(&matches)?;
let ret = match subcommand {
Commands::Make { target } => make::run(target),
Commands::Run { name, arguments } => run::run(name, arguments),
Commands::Setup {} => setup::run(),
Commands::Status {} => status::run(),
};
casile::show_outro();
command_status.farewell();
ret
}
Loading

0 comments on commit f448287

Please sign in to comment.