mirror of
https://github.com/crate-ci/typos.git
synced 2026-10-18 01:45:12 +02:00
refactor(codegen): Hard code data
This commit is contained in:
Generated
+1
@@ -804,6 +804,7 @@ dependencies = [
|
||||
"phf 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"phf_codegen 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"structopt 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"typos-dict 0.1.1",
|
||||
"unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ stages:
|
||||
steps:
|
||||
- template: azure/install-rust.yml@templates
|
||||
- script: |
|
||||
cargo run --package typos-codegen -- --input dict/typos/assets/words.csv --output dict/typos/src/dict_codegen.rs --check
|
||||
cargo run --package typos-codegen -- --output dict/typos/src/dict_codegen.rs --check
|
||||
displayName: Verify typos-dict
|
||||
- script: |
|
||||
cargo run --package codespell-codegen -- --output dict/codespell/src/dict_codegen.rs --check
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
use structopt::StructOpt;
|
||||
|
||||
fn generate<W: std::io::Write>(input: &[u8], file: &mut W) {
|
||||
pub const DICT: &[u8] = include_bytes!("../../assets/words.csv");
|
||||
|
||||
fn generate<W: std::io::Write>(file: &mut W) {
|
||||
writeln!(
|
||||
file,
|
||||
"// This file is code-genned by {}",
|
||||
@@ -16,7 +18,7 @@ fn generate<W: std::io::Write>(input: &[u8], file: &mut W) {
|
||||
)
|
||||
.unwrap();
|
||||
let mut builder = phf_codegen::Map::new();
|
||||
let records: Vec<_> = csv::Reader::from_reader(input)
|
||||
let records: Vec<_> = csv::Reader::from_reader(DICT)
|
||||
.records()
|
||||
.map(|r| r.unwrap())
|
||||
.collect();
|
||||
@@ -32,8 +34,6 @@ fn generate<W: std::io::Write>(input: &[u8], file: &mut W) {
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(rename_all = "kebab-case")]
|
||||
struct Options {
|
||||
#[structopt(long, parse(from_os_str))]
|
||||
input: std::path::PathBuf,
|
||||
#[structopt(flatten)]
|
||||
codegen: codegenrs::CodeGenArgs,
|
||||
#[structopt(flatten)]
|
||||
@@ -43,12 +43,8 @@ struct Options {
|
||||
fn run() -> Result<i32, Box<dyn std::error::Error>> {
|
||||
let options = Options::from_args();
|
||||
|
||||
let content = {
|
||||
let mut content = vec![];
|
||||
let input = std::fs::read(&options.input)?;
|
||||
generate(&input, &mut content);
|
||||
content
|
||||
};
|
||||
let mut content = vec![];
|
||||
generate(&mut content);
|
||||
|
||||
let content = String::from_utf8(content)?;
|
||||
let content = options.rustmft.reformat(&content)?;
|
||||
|
||||
Reference in New Issue
Block a user