From e6ab3454b6c7f40078958e71248ae799c02463c6 Mon Sep 17 00:00:00 2001 From: SRetip Date: Tue, 28 May 2024 18:16:55 +0300 Subject: [PATCH] import fix --- module/move/wca/src/ca/aggregator.rs | 2 +- module/move/wca/src/ca/formatter.rs | 2 +- module/move/wca/src/ca/grammar/command.rs | 12 ++++-------- module/move/wca/src/ca/grammar/dictionary.rs | 19 +++++++++---------- module/move/wca/src/ca/help.rs | 13 +++++++++---- module/move/wca/src/ca/verifier/verifier.rs | 1 - 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/module/move/wca/src/ca/aggregator.rs b/module/move/wca/src/ca/aggregator.rs index abf9a3a1ce..8336b1df29 100644 --- a/module/move/wca/src/ca/aggregator.rs +++ b/module/move/wca/src/ca/aggregator.rs @@ -142,7 +142,7 @@ pub( crate ) mod private let help_generator = std::mem::take( &mut ca.help_generator ).unwrap_or_default(); let help_variants = std::mem::take( &mut ca.help_variants ).unwrap_or_else( || HashSet::from([ HelpVariants::All ]) ); - + if help_variants.contains( &HelpVariants::All ) { HelpVariants::All.generate( &help_generator, dictionary, ca.order.unwrap_or_default() ); diff --git a/module/move/wca/src/ca/formatter.rs b/module/move/wca/src/ca/formatter.rs index 3b4f989f1d..368ec8e88f 100644 --- a/module/move/wca/src/ca/formatter.rs +++ b/module/move/wca/src/ca/formatter.rs @@ -3,7 +3,7 @@ pub( crate ) mod private use crate::*; use wtools::Itertools; - use crate::ca::aggregator::private::Order; + use ca::aggregator::private::Order; /// - #[ derive( Debug, Clone, PartialEq ) ] diff --git a/module/move/wca/src/ca/grammar/command.rs b/module/move/wca/src/ca/grammar/command.rs index ed1d4e8eee..46df984439 100644 --- a/module/move/wca/src/ca/grammar/command.rs +++ b/module/move/wca/src/ca/grammar/command.rs @@ -1,14 +1,10 @@ pub( crate ) mod private { use crate::*; - - use { Handler, Routine, Type }; - + use std::collections::{ BTreeMap, HashMap }; use former::{ Former, StoragePreform }; - use crate::ca::aggregator::private::Order; - use crate::ca::grammar::dictionary::private::CommandName; - use crate::wtools::Itertools; + use wtools::Itertools; /// A description of a Value in a command. Used to specify the expected type and provide a hint for the Value. /// @@ -102,7 +98,7 @@ pub( crate ) mod private pub subjects : Vec< ValueDescription >, /// Hints and types for command options. pub properties : BTreeMap< CommandName, ValueDescription >, - /// Last inserted command id. + /// Last inserted property id. #[ scalar( setter = false ) ] last_id : usize, /// Map of aliases. @@ -232,7 +228,7 @@ pub( crate ) mod private }; debug_assert!( !properties.contains_key( &property.name ), "Property name `{}` is already used for `{:?}`", property.name, properties[ &property.name ] ); super_former.storage.last_id = Some( super_former.storage.last_id.unwrap_or_default() + 1 ); - let name = CommandName{ id : super_former.storage.last_id.unwrap(), name : property.name.clone() }; + let name = CommandName { id : super_former.storage.last_id.unwrap(), name : property.name.clone() }; properties.insert( name, value ); let mut aliases = super_former.storage.properties_aliases.unwrap_or_default(); diff --git a/module/move/wca/src/ca/grammar/dictionary.rs b/module/move/wca/src/ca/grammar/dictionary.rs index 86c4f5b6db..57ad3f1d71 100644 --- a/module/move/wca/src/ca/grammar/dictionary.rs +++ b/module/move/wca/src/ca/grammar/dictionary.rs @@ -1,14 +1,10 @@ pub( crate ) mod private { - use std::cmp::Ordering; use crate::*; - - use { Command }; - use std::collections::BTreeMap; - use std::fmt::Display; use former::Former; - use crate::ca::aggregator::private::Order; - use crate::wtools::Itertools; + use wtools::Itertools; + use std::cmp::Ordering; + use std::collections::BTreeMap; // qqq : `Former` does not handle this situation well @@ -22,7 +18,9 @@ pub( crate ) mod private #[ derive( Debug, Default, Clone, Eq ) ] pub struct CommandName { + /// id of command. pub( crate ) id : usize, + /// Name of command. pub name : String, } @@ -86,7 +84,7 @@ pub( crate ) mod private { let mut commands = self.storage.commands.unwrap_or_default(); self.storage.dictionary_last_id = Some( self.storage.dictionary_last_id.unwrap_or_default() + 1 ); - let name = CommandName{ id : self.storage.dictionary_last_id.unwrap(), name : command.phrase.clone() }; + let name = CommandName { id : self.storage.dictionary_last_id.unwrap(), name : command.phrase.clone() }; commands.insert( name, command ); self.storage.commands = Some( commands ); @@ -104,7 +102,7 @@ pub( crate ) mod private pub fn register( &mut self, command : Command ) -> Option< Command > { self.dictionary_last_id += 1; - let name = CommandName{ id : self.dictionary_last_id, name : command.phrase.clone() }; + let name = CommandName { id : self.dictionary_last_id, name : command.phrase.clone() }; self.commands.insert( name, command ) } @@ -122,7 +120,7 @@ pub( crate ) mod private where Name : std::hash::Hash + Eq + Ord + ToString, { - self.commands.iter().find( |(k, _)| k.name == name.to_string() ).map(|(_, v)| v) + self.commands.iter().find( | ( k, _ ) | k.name == name.to_string() ).map( | ( _, v ) | v ) } /// Find commands that match a given name part. @@ -167,4 +165,5 @@ pub( crate ) mod private crate::mod_interface! { exposed use Dictionary; + exposed use CommandName; } diff --git a/module/move/wca/src/ca/help.rs b/module/move/wca/src/ca/help.rs index a1ff2ef880..cc8c897b70 100644 --- a/module/move/wca/src/ca/help.rs +++ b/module/move/wca/src/ca/help.rs @@ -4,15 +4,20 @@ pub( crate ) mod private use ca:: { Command, - Routine, Type, formatter::private::{ HelpFormat, md_generator }, + Routine, + Type, + formatter::private:: + { + HelpFormat, + md_generator + }, + tool::table::format_table, }; use wtools::Itertools; use std::rc::Rc; use error_tools::for_app::anyhow; use former::Former; - use ca::tool::table::format_table; - use crate::ca::aggregator::private::Order; // qqq : for Bohdan : it should transparent mechanist which patch list of commands, not a stand-alone mechanism @@ -99,7 +104,7 @@ pub( crate ) mod private let footer = if o.with_footer { let full_subjects = command.subjects.iter().map( | subj | format!( "- {} [{}{:?}]", subj.hint, if subj.optional { "?" } else { "" }, subj.kind ) ).join( "\n\t" ); - let full_properties = format_table( command.properties( dictionary.order ).into_iter().map( | ( name, value ) | [ name.clone(), format!( "- {} [{}{:?}]", value.hint, if value.optional { "?" } else { "" }, value.kind ) ] )).unwrap().replace( '\n', "\n\t" ); + let full_properties = format_table( command.properties( dictionary.order ).into_iter().map( | ( name, value ) | [ name.clone(), format!( "- {} [{}{:?}]", value.hint, if value.optional { "?" } else { "" }, value.kind ) ] ) ).unwrap().replace( '\n', "\n\t" ); format! ( diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index 0c898969fa..8fe25073d3 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -7,7 +7,6 @@ pub( crate ) mod private use std::collections::{ BTreeMap, HashMap }; use wtools::{ error, error::Result, err }; use ca::help::private::{ HelpGeneratorOptions, LevelOfDetail, generate_help_content }; - use crate::ca::grammar::dictionary::private::CommandName; /// Converts a `ParsedCommand` to a `VerifiedCommand` by performing validation and type casting on values. ///