Skip to content

Commit

Permalink
Revert "chore: attempt to fix kdl v1-fallback"
Browse files Browse the repository at this point in the history
This reverts commit 8c0a2c6.
  • Loading branch information
jdx committed Jan 10, 2025
1 parent ef98628 commit c440c2a
Show file tree
Hide file tree
Showing 23 changed files with 37 additions and 39 deletions.
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ indexmap = "2"
itertools = "0.14"
kdl = "6"
log = "0.4"
miette7 = { version = "7", features = ["fancy"], package = "miette" }
miette = { version = "7", features = ["fancy"] }
once_cell = "1"
regex = "1"
serde = { version = "1", features = ["derive"] }
Expand Down
6 changes: 3 additions & 3 deletions cli/src/cli/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::process::Stdio;

use clap::Args;
use itertools::Itertools;
use miette7::IntoDiagnostic;
use miette::IntoDiagnostic;

use usage::Spec;

Expand Down Expand Up @@ -32,7 +32,7 @@ pub struct Bash {
}

impl Bash {
pub fn run(&mut self) -> miette7::Result<()> {
pub fn run(&mut self) -> miette::Result<()> {
let (spec, _script) = Spec::parse_file(&self.script)?;
let mut args = self.args.clone();
args.insert(0, spec.bin.clone());
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Bash {
Ok(())
}

pub fn help(&self, spec: &Spec, args: &[String], long: bool) -> miette7::Result<()> {
pub fn help(&self, spec: &Spec, args: &[String], long: bool) -> miette::Result<()> {
let parsed = usage::parse::parse_partial(spec, args)?;
println!("{}", usage::docs::cli::render_help(spec, &parsed.cmd, long));
Ok(())
Expand Down
8 changes: 4 additions & 4 deletions cli/src/cli/complete_word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::process::Command;

use clap::Args;
use itertools::Itertools;
use miette7::IntoDiagnostic;
use miette::IntoDiagnostic;
use once_cell::sync::Lazy;
use xx::process::check_status;
use xx::{regex, XXError, XXResult};
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct CompleteWord {
}

impl CompleteWord {
pub fn run(&self) -> miette7::Result<()> {
pub fn run(&self) -> miette::Result<()> {
let spec = generate::file_or_spec(&self.file, &self.spec)?;
let choices = self.complete_word(&spec)?;
let shell = self.shell.as_deref().unwrap_or_default();
Expand All @@ -59,7 +59,7 @@ impl CompleteWord {
Ok(())
}

fn complete_word(&self, spec: &Spec) -> miette7::Result<Vec<(String, String)>> {
fn complete_word(&self, spec: &Spec) -> miette::Result<Vec<(String, String)>> {
let cword = self.cword.unwrap_or(self.words.len().max(1) - 1);
let ctoken = self.words.get(cword).cloned().unwrap_or_default();
let words: Vec<_> = self.words.iter().take(cword).cloned().collect();
Expand Down Expand Up @@ -188,7 +188,7 @@ impl CompleteWord {
cmd: &SpecCommand,
arg: &SpecArg,
ctoken: &str,
) -> miette7::Result<Vec<(String, String)>> {
) -> miette::Result<Vec<(String, String)>> {
static EMPTY_COMPL: Lazy<SpecComplete> = Lazy::new(SpecComplete::default);

trace!("complete_arg: {arg} {ctoken}");
Expand Down
4 changes: 2 additions & 2 deletions cli/src/cli/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::path::PathBuf;
use std::process::Stdio;

use clap::Args;
use miette7::IntoDiagnostic;
use miette::IntoDiagnostic;

use usage::Spec;

Expand All @@ -20,7 +20,7 @@ pub struct Exec {
}

impl Exec {
pub fn run(&mut self) -> miette7::Result<()> {
pub fn run(&mut self) -> miette::Result<()> {
let parent = self
.bin
.parent()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli/generate/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub struct Completion {
}

impl Completion {
pub fn run(&self) -> miette7::Result<()> {
pub fn run(&self) -> miette::Result<()> {
// TODO: refactor this
let (spec, _) = match &self.file {
Some(file) => Spec::parse_file(file)?,
Expand Down
4 changes: 2 additions & 2 deletions cli/src/cli/generate/fig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ impl FigCommand {
}

impl Fig {
pub fn run(&self) -> miette7::Result<()> {
let write = |path: &PathBuf, md: &str| -> miette7::Result<()> {
pub fn run(&self) -> miette::Result<()> {
let write = |path: &PathBuf, md: &str| -> miette::Result<()> {
println!("writing to {}", path.display());
xx::file::write(path, format!("{}\n", md.trim()))?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli/generate/json.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cli::generate;
use crate::Result;
use miette7::IntoDiagnostic;
use miette::IntoDiagnostic;
use std::path::PathBuf;

/// Outputs a usage spec in json format
Expand Down
4 changes: 2 additions & 2 deletions cli/src/cli/generate/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ pub struct Markdown {
}

impl Markdown {
pub fn run(&self) -> miette7::Result<()> {
let write = |path: &PathBuf, md: &str| -> miette7::Result<()> {
pub fn run(&self) -> miette::Result<()> {
let write = |path: &PathBuf, md: &str| -> miette::Result<()> {
println!("writing to {}", path.display());
xx::file::write(path, format!("{}\n", md.trim()))?;
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli/generate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum Command {
}

impl Generate {
pub fn run(&self) -> miette7::Result<()> {
pub fn run(&self) -> miette::Result<()> {
match &self.command {
Command::Completion(cmd) => cmd.run(),
Command::Fig(cmd) => cmd.run(),
Expand Down
2 changes: 1 addition & 1 deletion cli/src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::usage_spec;
use clap::{Parser, Subcommand};
use miette7::Result;
use miette::Result;

mod bash;
mod complete_word;
Expand Down
1 change: 0 additions & 1 deletion cli/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use miette::Diagnostic;
use miette7 as miette;
use thiserror::Error;

#[derive(Error, Diagnostic, Debug)]
Expand Down
4 changes: 2 additions & 2 deletions cli/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#[macro_use]
extern crate log;
extern crate miette7;
extern crate miette;
extern crate xx;

use std::path::PathBuf;

use miette7::Result;
use miette::Result;

use cli::Cli;

Expand Down
2 changes: 1 addition & 1 deletion cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use env_logger::Env;
use usage_cli::env;

fn main() -> miette7::Result<()> {
fn main() -> miette::Result<()> {
set_log_env_vars();
env_logger::builder()
.format_timestamp(None)
Expand Down
6 changes: 3 additions & 3 deletions cli/src/shebang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::fs;
use std::os::unix::prelude::*;
use std::path::{Path, PathBuf};

use miette7::IntoDiagnostic;
use miette::IntoDiagnostic;

use usage::Spec;

use crate::{env, hash};

pub fn execute(script: &Path, args: &[String]) -> miette7::Result<()> {
pub fn execute(script: &Path, args: &[String]) -> miette::Result<()> {
let (_schema, body) = Spec::parse_file(script)?;
// let cmd: Command = (&schema).into();
// let m = cmd.get_matches_from(args[1..].to_vec());
Expand Down Expand Up @@ -52,7 +52,7 @@ pub fn execute(script: &Path, args: &[String]) -> miette7::Result<()> {
// String::from_utf8(out.stdout).into_diagnostic()
// }

fn create_script(script: &Path, body: &str) -> miette7::Result<PathBuf> {
fn create_script(script: &Path, body: &str) -> miette::Result<PathBuf> {
let tmp_filename = script.file_name().unwrap().to_str().unwrap();
let tmp_filename = tmp_filename
.to_ascii_lowercase()
Expand Down
2 changes: 1 addition & 1 deletion cli/src/usage_spec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::cli::Cli;
use clap::CommandFactory;
use miette7::Result;
use miette::Result;

pub(crate) fn generate() -> Result<()> {
let mut cli = Cli::command().version(env!("CARGO_PKG_VERSION"));
Expand Down
2 changes: 1 addition & 1 deletion cli/usage.usage.kdl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name usage-cli
bin usage
version "2.0.1"
version "2.0.2"
about "CLI for working with usage-based CLIs"
usage "Usage: usage-cli [OPTIONS] [COMPLETIONS] <COMMAND>"
flag --usage-spec help="Outputs a `usage.kdl` spec for this CLI itself"
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/reference/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@
"config": {
"props": {}
},
"version": "2.0.1",
"version": "2.0.2",
"usage": "Usage: usage-cli [OPTIONS] [COMPLETIONS] <COMMAND>",
"complete": {},
"source_code_link_template": "https://github.com/jdx/usage/blob/main/cli/src/cli/{{path}}.rs",
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Usage**: `usage [--usage-spec] [COMPLETIONS] <SUBCOMMAND>`

**Version**: 2.0.1
**Version**: 2.0.2

- **Usage**: `usage [--usage-spec] [COMPLETIONS] <SUBCOMMAND>`

Expand Down
2 changes: 1 addition & 1 deletion lib/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ indexmap = { version = "2", features = ["serde"] }
itertools = "0.14"
kdl = "6"
log = "0.4"
miette7 = { version = "7", package = "miette" }
miette = "7"
once_cell = "1"
regex = "1"
serde = { version = "1", features = ["derive"] }
Expand Down
7 changes: 3 additions & 4 deletions lib/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use miette7 as miette;
use miette7::{Diagnostic, NamedSource, SourceSpan};
use miette::{Diagnostic, NamedSource, SourceSpan};
use thiserror::Error;

#[derive(Error, Diagnostic, Debug)]
Expand Down Expand Up @@ -53,13 +52,13 @@ pub type Result<T> = std::result::Result<T, UsageErr>;
#[macro_export]
macro_rules! bail_parse {
($ctx:expr, $span:expr, $fmt:literal) => {{
let span: miette7::SourceSpan = ($span.offset(), $span.len()).into();
let span: miette::SourceSpan = ($span.offset(), $span.len()).into();
let msg = format!($fmt);
let err = $ctx.build_err(msg, span);
return std::result::Result::Err(err);
}};
($ctx:expr, $span:expr, $fmt:literal, $($arg:tt)*) => {{
let span: miette7::SourceSpan = ($span.offset(), $span.len()).into();
let span: miette::SourceSpan = ($span.offset(), $span.len()).into();
let msg = format!($fmt, $($arg)*);
let err = $ctx.build_err(msg, span);
return std::result::Result::Err(err);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use heck::ToSnakeCase;
use indexmap::IndexMap;
use itertools::Itertools;
use log::trace;
use miette7::bail;
use miette::bail;
use std::collections::{BTreeMap, VecDeque};
use std::fmt::{Debug, Display, Formatter};
use strum::EnumTryAs;
Expand Down Expand Up @@ -30,7 +30,7 @@ pub enum ParseValue {
MultiString(Vec<String>),
}

pub fn parse(spec: &Spec, input: &[String]) -> Result<ParseOutput, miette7::Error> {
pub fn parse(spec: &Spec, input: &[String]) -> Result<ParseOutput, miette::Error> {
let mut out = parse_partial(spec, input)?;
trace!("{out:?}");
for arg in out.cmd.args.iter().skip(out.args.len()) {
Expand Down Expand Up @@ -61,7 +61,7 @@ pub fn parse(spec: &Spec, input: &[String]) -> Result<ParseOutput, miette7::Erro
Ok(out)
}

pub fn parse_partial(spec: &Spec, input: &[String]) -> Result<ParseOutput, miette7::Error> {
pub fn parse_partial(spec: &Spec, input: &[String]) -> Result<ParseOutput, miette::Error> {
trace!("parse_partial: {input:?}");
let mut input = input.iter().cloned().collect::<VecDeque<_>>();
input.pop_front();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/spec/context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::error::UsageErr;
use miette7::{NamedSource, SourceSpan};
use miette::{NamedSource, SourceSpan};
use std::path::{Path, PathBuf};

#[derive(Debug, Default)]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/spec/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use indexmap::IndexMap;
use kdl::{KdlEntry, KdlNode, KdlValue};
use miette7::SourceSpan;
use miette::SourceSpan;
use std::fmt::Debug;
use std::ops::RangeBounds;

Expand Down

0 comments on commit c440c2a

Please sign in to comment.