Skip to content

Commit

Permalink
chore(fmt): add rustfmt.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
2moe committed May 3, 2024
1 parent 7de938f commit 1052617
Show file tree
Hide file tree
Showing 24 changed files with 24,741 additions and 16,243 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
!/core
!/assets
!/Cargo.lock
!/rustfmt.toml

# black list
target
Expand Down
3 changes: 2 additions & 1 deletion cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const EARLY_RT: bool = true;
// const EARLY_RT: bool = false;

use std::{borrow::Cow, collections::HashMap, ffi::OsStr, io, path::PathBuf};

use glossa_codegen::{
consts::*,
highlight::{HighLight, HighLightFmt, HighLightRes},
prelude::*,
};
use std::{borrow::Cow, collections::HashMap, ffi::OsStr, io, path::PathBuf};

fn main() -> io::Result<()> {
let ver = get_pkg_version!();
Expand Down
19,614 changes: 11,862 additions & 7,752 deletions cli/src/assets/localisation.rs

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions cli/src/opt/args.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::path::PathBuf;

use clap::{ColorChoice, Parser, Subcommand};
use getset::Getters;
use glossa::GetText;

use crate::{
assets::get_l10n_text,
opt::{conversion::ConvOpts, get::GetOpts, get_md, set::SetOpts, PKG_VERSION},
};
use clap::{ColorChoice, Parser, Subcommand};
use getset::Getters;
use glossa::GetText;
use std::path::PathBuf;

#[derive(Parser, Debug, Getters)]
#[getset(get = "pub(crate) with_prefix")]
Expand Down
10 changes: 6 additions & 4 deletions cli/src/opt/conversion.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use std::path::PathBuf;

use clap::Parser;
use getset::Getters;
use glossa::GetText;

use crate::{
assets::get_l10n_text,
opt::{get_md, sample_directory},
};
use clap::Parser;
use getset::Getters;
use glossa::GetText;
use std::path::PathBuf;

#[derive(Parser, Debug, Getters)]
#[getset(get = "pub(crate) with_prefix")]
Expand Down
3 changes: 2 additions & 1 deletion cli/src/opt/get.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use std::path::PathBuf;

use crate::opt::{get_opt_md, get_opt_text, sample_directory};
use clap::Parser;
use getset::Getters;

use crate::opt::{get_opt_md, get_opt_text, sample_directory};

/// `tomlyre get /path/to/file -k x.y.z`
#[derive(Parser, Debug, Getters)]
#[getset(get = "pub(crate) with_prefix")]
Expand Down
8 changes: 5 additions & 3 deletions cli/src/opt/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use std::env;

use glossa::GetText;
use hlight::{gen_syntax_highlight, theme::theme_monokai};

use crate::{
assets::get_l10n_text,
opt::theme::{
get_env_theme_bg, get_highlight_resource_from_os_env, get_static_theme_style,
},
};
use glossa::GetText;
use hlight::{gen_syntax_highlight, theme::theme_monokai};
use std::env;

pub(crate) const PKG_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand Down
6 changes: 4 additions & 2 deletions cli/src/opt/set.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::opt::{get_opt_md, get_opt_text, sample_directory};
use std::path::PathBuf;

use clap::Parser;
use getset::Getters;
use std::path::PathBuf;

use crate::opt::{get_opt_md, get_opt_text, sample_directory};

#[derive(Parser, Debug, Getters)]
#[getset(get = "pub(crate) with_prefix")]
Expand Down
18 changes: 10 additions & 8 deletions cli/src/opt/theme.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
use crate::{assets::get_l10n_text, opt::args::Cli};
use glossa::{assets::OnceCell, GetText};
use hlight::{
gen_syntax_highlight,
theme::{dumps, ThemeSet},
HighLightRes,
};
use log_l10n::level::color::OwoColorize;
use std::{
borrow::Cow,
env,
Expand All @@ -14,6 +6,16 @@ use std::{
process::exit,
};

use glossa::{assets::OnceCell, GetText};
use hlight::{
gen_syntax_highlight,
theme::{dumps, ThemeSet},
HighLightRes,
};
use log_l10n::level::color::OwoColorize;

use crate::{assets::get_l10n_text, opt::args::Cli};

const SAMPLE_HIGHLIGHT_TEXT: &str = r#"
[[bin]]
doc = false
Expand Down
25 changes: 15 additions & 10 deletions cli/src/parser/completion.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use crate::{assets::get_l10n_text, opt::args::Cli};
use std::{
env,
io::{self, BufWriter, Write},
};

use clap::CommandFactory;
use clap_complete::{generate, shells, Generator};
use glossa::GetText;
use hlight::{gen_syntax_highlight, HighLightRes};
use log::info;
use std::{
env,
io::{self, BufWriter, Write},
};

use crate::{assets::get_l10n_text, opt::args::Cli};
// use tomlyre::highlight::{output::gen_syntax_highlight, HighLightRes};

const BIN_NAME: &str = env!("CARGO_BIN_NAME");
Expand All @@ -31,7 +33,9 @@ pub(crate) fn get_shell_completion(
args: &Cli,
theme: &HighLightRes,
) -> anyhow::Result<()> {
let Some(sh) = args.get_shell_completion() else { return Ok(()) };
let Some(sh) = args.get_shell_completion() else {
return Ok(());
};

fn gen<G: Generator>(g: G) -> Vec<u8> {
gen_completion(g)
Expand Down Expand Up @@ -77,9 +81,10 @@ pub(crate) fn get_shell_completion(

#[cfg(test)]
mod tests {
use super::*;
use anyhow::Result;

use super::*;

#[test]
fn get_zsh_comp() -> Result<()> {
let v = gen_completion(shells::Zsh);
Expand All @@ -101,18 +106,18 @@ mod tests {
#compdef tomlyre
autoload -U is-at-least
_tomlyre() {
typeset -A opt_args
typeset -a _arguments_options
local ret=1
if is-at-least 5.2; then
_arguments_options=(-s -S -C)
else
_arguments_options=(-s -C)
fi
local context curcontext="$curcontext" state line
_arguments "${_arguments_options[@]}" \
"#;
Expand Down
18 changes: 10 additions & 8 deletions cli/src/parser/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
use crate::{
opt::{args::Cli, theme::get_env_theme_bg, PKG_VERSION},
parser::{completion::get_shell_completion, sub_cmd::handle_sub_cmds},
};
use anyhow::Result;
use clap::Parser;
use log::{debug, trace};
use log_l10n::level::color::OwoColorize;
use std::{
borrow::Cow,
io::{BufWriter, Write},
process::exit,
};

use anyhow::Result;
use clap::Parser;
use log::{debug, trace};
use log_l10n::level::color::OwoColorize;
use tomlyre::table::{set_header, Table, STYLES};

use crate::{
opt::{args::Cli, theme::get_env_theme_bg, PKG_VERSION},
parser::{completion::get_shell_completion, sub_cmd::handle_sub_cmds},
};
mod completion;
mod set_opts;
mod sub_cmd;
Expand Down
6 changes: 4 additions & 2 deletions cli/src/parser/set_opts.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use crate::opt::{args::Cli, set::SetOpts};
use std::{borrow::Cow, process::exit, str::FromStr};

use anyhow::Result;
use hlight::HighLightRes;
use std::{borrow::Cow, process::exit, str::FromStr};
use tomlyre::set::{
Array, ArrayOfTables, CfgOpts, Datetime, InlineTable, TomlKey, TomlTable,
TomlValue, Value,
};

use crate::opt::{args::Cli, set::SetOpts};

/// The function first calls the `set_value` method on the provided `cfg_opts` with the input value converted into a `Some` option using the `Into` trait.
/// If this succeeds, indicating that the value was successfully set in the `CfgOpts`, the function then calls the `exit` function with a status code of 0, terminating the program.
fn set_value_and_exit<V: Into<Value>>(cfg_opts: &CfgOpts, v: V) -> Result<()> {
Expand Down
10 changes: 6 additions & 4 deletions cli/src/parser/sub_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
use std::borrow::Cow;

use anyhow::Result;
use hlight::HighLightRes;
use tomlyre::{conversion, get::get_config_file, set::TomlKey};

use crate::{
opt::{
args::{Cli, Sub},
Expand All @@ -6,10 +12,6 @@ use crate::{
},
parser::set_opts::handle_setopts,
};
use anyhow::Result;
use hlight::HighLightRes;
use std::borrow::Cow;
use tomlyre::{conversion, get::get_config_file, set::TomlKey};

/// All subcommands are handled here.
///
Expand Down
3 changes: 2 additions & 1 deletion core/build.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
const EARLY_RT: bool = true;
// const EARLY_RT: bool = false;

use std::{borrow::Cow, collections::HashMap, ffi::OsStr, io, path::PathBuf};

use glossa_codegen::{
consts::*,
highlight::{HighLight, HighLightFmt, HighLightRes},
prelude::*,
};
use std::{borrow::Cow, collections::HashMap, ffi::OsStr, io, path::PathBuf};

fn main() -> io::Result<()> {
gen_10n_text()?;
Expand Down
Loading

0 comments on commit 1052617

Please sign in to comment.