Skip to content

Commit

Permalink
import fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SRetip committed May 28, 2024
1 parent 7279338 commit e6ab345
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion module/move/wca/src/ca/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down
2 changes: 1 addition & 1 deletion module/move/wca/src/ca/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ]
Expand Down
12 changes: 4 additions & 8 deletions module/move/wca/src/ca/grammar/command.rs
Original file line number Diff line number Diff line change
@@ -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.
///
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
19 changes: 9 additions & 10 deletions module/move/wca/src/ca/grammar/dictionary.rs
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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,
}

Expand Down Expand Up @@ -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 );

Expand All @@ -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 )
}

Expand All @@ -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.
Expand Down Expand Up @@ -167,4 +165,5 @@ pub( crate ) mod private
crate::mod_interface!
{
exposed use Dictionary;
exposed use CommandName;
}
13 changes: 9 additions & 4 deletions module/move/wca/src/ca/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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!
(
Expand Down
1 change: 0 additions & 1 deletion module/move/wca/src/ca/verifier/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit e6ab345

Please sign in to comment.