Skip to content

Commit bfd1e24

Browse files
committed
Merge branch 'main' into make
2 parents b4725d4 + 3509eb9 commit bfd1e24

File tree

34 files changed

+648
-221
lines changed

34 files changed

+648
-221
lines changed

Cargo.lock

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

awk/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition.workspace = true
77
rust-version.workspace = true
88

99
[dependencies]
10-
plib = { path = "../plib" }
1110
gettext-rs.workspace = true
1211
clap.workspace = true
1312
libc.workspace = true
@@ -17,6 +16,9 @@ lazy_static = "1.4"
1716
lexical = { version = "6.1", features = ["format"] }
1817
rand = {version = "0.8", default-features = false, features = ["small_rng"] }
1918

19+
[dev-dependencies]
20+
plib = { path = "../plib" }
21+
2022
[lints]
2123
workspace = true
2224

awk/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use crate::compiler::compile_program;
1111
use crate::interpreter::interpret;
1212
use clap::Parser;
1313
use compiler::SourceFile;
14-
use gettextrs::{bind_textdomain_codeset, gettext, textdomain};
15-
use plib::PROJECT_NAME;
14+
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
1615
use std::error::Error;
1716
use std::fmt::Display;
1817
use std::io::Read;
@@ -56,8 +55,9 @@ fn exit_if_error<T, U: Display>(r: Result<T, U>) -> T {
5655
}
5756

5857
fn main() -> Result<(), Box<dyn Error>> {
59-
textdomain(PROJECT_NAME)?;
60-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
58+
setlocale(LocaleCategory::LcAll, "");
59+
textdomain(env!("PROJECT_NAME"))?;
60+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
6161

6262
let args = Args::parse();
6363

awk/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use plib::{run_test, run_test_with_checker, TestPlan};
1+
use plib::testing::{run_test, run_test_with_checker, TestPlan};
22

33
fn test_awk(args: Vec<String>, expected_output: &str) {
44
run_test(TestPlan {

calc/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition.workspace = true
77
rust-version.workspace = true
88

99
[dependencies]
10-
plib = { path = "../plib" }
1110
gettext-rs.workspace = true
1211
regex.workspace = true
1312
clap.workspace = true
@@ -17,6 +16,9 @@ lazy_static = "1.4"
1716
bigdecimal = "0.4"
1817
rustyline = { version = "14.0", default-features = false }
1918

19+
[dev-dependencies]
20+
plib = { path = "../plib" }
21+
2022
[lints]
2123
workspace = true
2224

calc/bc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ use bc_util::{
1616
use clap::Parser;
1717

1818
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
19-
use plib::PROJECT_NAME;
2019
use rustyline::{error::ReadlineError, DefaultEditor, Result};
2120

2221
mod bc_util;
@@ -45,10 +44,11 @@ fn print_output_or_error(result: ExecutionResult<String>) {
4544

4645
fn main() -> Result<()> {
4746
setlocale(LocaleCategory::LcAll, "");
48-
textdomain(PROJECT_NAME)?;
49-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
47+
textdomain(env!("PROJECT_NAME"))?;
48+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
5049

5150
let args = Args::parse();
51+
5252
let mut interpreter = Interpreter::default();
5353

5454
if args.define_math_functions {

calc/expr.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
//
99

1010
use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
11-
use plib::PROJECT_NAME;
1211
use regex::Regex;
1312

1413
#[derive(Clone, Debug, PartialEq)]
@@ -370,10 +369,9 @@ fn eval_expression(tokens: &[Token]) -> Result<Token, &'static str> {
370369
}
371370

372371
fn main() -> Result<(), Box<dyn std::error::Error>> {
373-
// initialize translations
374372
setlocale(LocaleCategory::LcAll, "");
375-
textdomain(PROJECT_NAME)?;
376-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
373+
textdomain(env!("PROJECT_NAME"))?;
374+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
377375

378376
// tokenize and evaluate the expression
379377
let arg_tokens = tokenize();

calc/tests/bc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10-
use plib::{run_test, TestPlan};
10+
use plib::testing::{run_test, TestPlan};
1111

1212
fn test_bc(program: &str, expected_output: &str) {
1313
run_test(TestPlan {

calc/tests/expr/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10-
use plib::{run_test, TestPlan};
10+
use plib::testing::{run_test, TestPlan};
1111

1212
fn expr_test(args: &[&str], expected_output: &str) {
1313
let str_args: Vec<String> = args.iter().map(|s| String::from(*s)).collect();

datetime/time.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ use plib::PROJECT_NAME;
2222
#[command(
2323
version,
2424
about = gettext("time - time a simple command or give resource usage"),
25-
help_template = gettext("{about-with-newline}\nUsage: {usage}\n\nArguments:\n{positionals}\n\nOptions:\n{options}")
25+
help_template = gettext("{about}\n\nUsage: {usage}\n\nArguments:\n{positionals}\n\nOptions:\n{options}"),
26+
disable_help_flag = true,
27+
disable_version_flag = true,
2628
)]
2729
struct Args {
2830
#[arg(
@@ -41,6 +43,12 @@ struct Args {
4143
help = gettext("Arguments for the utility")
4244
)]
4345
arguments: Vec<String>,
46+
47+
#[arg(short, long, help = gettext("Print help"), action = clap::ArgAction::HelpLong)]
48+
help: Option<bool>,
49+
50+
#[arg(short = 'V', long, help = gettext("Print version"), action = clap::ArgAction::Version)]
51+
version: Option<bool>,
4452
}
4553

4654
enum TimeError {

0 commit comments

Comments
 (0)