Skip to content

Commit

Permalink
Merge pull request #1355 from Barsik-sus/wca-willbe-former
Browse files Browse the repository at this point in the history
READY: (wca, willbe, former): processing `qqq`, adding a test
  • Loading branch information
Wandalen committed May 29, 2024
2 parents b02d13e + ed4a8ce commit f0d3981
Show file tree
Hide file tree
Showing 16 changed files with 64 additions and 32 deletions.
35 changes: 35 additions & 0 deletions module/core/former/tests/inc/former_tests/tuple_struct.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#![ deny( missing_docs ) ]

#[ allow( unused_imports ) ]
use super::*;

use collection_tools::HashMap;

type Key = &'static str;
type Value = &'static str;

#[ derive( Debug, PartialEq, former::Former ) ]
pub struct Struct1( #[ subform_collection ] HashMap< Key, Value > );

impl Struct1
{
pub fn get( &self, key : Key ) -> Option< &Value >
{
self.0.get( key )
}
}

#[ test ]
fn example()
{
// form a key-value store
let instance = Struct1::former()
.map()
.add( ( "first", "Value1" ) )
.add( ( "second", "Value2" ) )
.end()
.form();

// now it is a read-only storage with pre-configured data
assert_eq!( Some( &"Value1" ), instance.get( "first" ) );
}
1 change: 1 addition & 0 deletions module/core/former/tests/inc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ mod former_tests
mod a_basic;
mod a_primitives_manual;
mod a_primitives;
mod tuple_struct;

#[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ]
mod subform_collection_basic_scalar;
Expand Down
4 changes: 2 additions & 2 deletions module/move/wca/src/ca/executor/routine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub( crate ) mod private
}
}

// qqq : make 0-arguments, 1-argument, 2-arguments, 3 arguments versions
// aaa : make 0-arguments, 1-argument, 2-arguments, 3 arguments versions
// aaa : done. now it works with the following variants:
// fn(), fn(args), fn(props), fn(args, props), fn(context), fn(context, args), fn(context, props), fn(context, args, props)

Expand Down Expand Up @@ -297,7 +297,7 @@ pub( crate ) mod private
}
}

// qqq : why Rc is necessary? why not just box?
// aaa : why Rc is necessary? why not just box?
// aaa : to be able to clone Routines

impl PartialEq for Routine
Expand Down
3 changes: 2 additions & 1 deletion module/move/wca/src/ca/grammar/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pub( crate ) mod private
{
name : String,
// qqq : how to re-use ValueDescriptionFormer without additional end?
// #[subform_scalar]
// value : ValueDescription,
/// providing guidance to the user for entering a valid value
hint : String,
Expand Down Expand Up @@ -103,7 +104,7 @@ pub( crate ) mod private
/// Map of aliases.
// Aliased key -> Original key
pub properties_aliases : HashMap< String, String >,
// qqq : for Bohdan : routine should also be here
// aaa : for Bohdan : routine should also be here
// aaa : here it is
// qqq : make it usable and remove default(?)
/// The type `Routine` represents the specific implementation of the routine.
Expand Down
7 changes: 4 additions & 3 deletions module/move/wca/src/ca/parser/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ pub( crate ) mod private
/// A `Program` consists of one or more commannd
///
/// The program can be executed by iterating over each commands and executing it
// qqq : xxx : for Bohdan : Commands should be here instead of Namespace
// qqq : remove concept Namespace
// qqq : introduce concept Dictionary for grammar
// aaa : xxx : for Bohdan : Commands should be here instead of Namespace
// aaa : remove concept Namespace
// aaa : introduce concept Dictionary for grammar
// aaa : done
#[ derive( Debug, Clone, PartialEq, Eq ) ]
pub struct Program< Command >
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ mod private
let repo_url = url::extract_repo_url( &self.repository_url ).and_then( | r | url::git_info_extract( &r ).ok() ).ok_or_else::< Error, _ >( || err!( "Fail to parse repository url" ) )?;
let example = if let Some( name ) = find_example_file( self.module_path.as_path(), &self.module_name )
{
// qqq : for Bohdan : Hardcoded Strings, would be better to use `PathBuf` to avoid separator mismatch on Windows and Unix
// qqq : for Petro : Hardcoded Strings, would be better to use `PathBuf` to avoid separator mismatch on Windows and Unix
let p = name.strip_prefix( workspace_path ).unwrap().get( 1.. ).unwrap().replace( "\\","%2F" );
let name = name.replace( "/", "\\" );
let name = name.split( "\\" ).last().unwrap().split( "." ).next().unwrap();
Expand Down
3 changes: 1 addition & 2 deletions module/move/willbe/src/command/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ mod private
use action::{ list as l, list::{ ListFormat, ListOptions } };
use former::Former;

// qqq: `Former` forces the struct to be public
#[ derive( Former ) ]
pub struct ListProperties
struct ListProperties
{
#[ former( default = ListFormat::Tree ) ]
format : ListFormat,
Expand Down
1 change: 0 additions & 1 deletion module/move/willbe/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ with_gitpod: If set to 1, a column with a link to Gitpod will be added. Clicking
.routine( command::test )
.end()

// qqq : is it right?
.command( "cicd.renew" )
.hint( "generate a CI/CD for the workspace" )
.long_hint( "this command generates a development workflow for the entire workspace inferred from the current directory. The workflow outlines the build steps, dependencies, test processes, and more for all modules within the workspace." )
Expand Down
3 changes: 1 addition & 2 deletions module/move/willbe/src/command/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ mod private
use former::Former;
use std::fmt::Write;

// qqq: `Former` forces the struct to be public
#[ derive( Former ) ]
pub struct PublishProperties
struct PublishProperties
{
#[ former( default = true ) ]
dry : bool,
Expand Down
3 changes: 1 addition & 2 deletions module/move/willbe/src/command/publish_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ mod private
use wtools::error::Result;
use _path::AbsolutePath;

// qqq: `Former` forces the struct to be public
#[ derive( former::Former ) ]
pub struct PublishDiffProperties
struct PublishDiffProperties
{
keep_archive : Option< PathBuf >,
}
Expand Down
3 changes: 1 addition & 2 deletions module/move/willbe/src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ mod private
use error_tools::for_app::bail;
use optimization::Optimization;

// qqq: `Former` forces the struct to be public
#[ derive( Former, Debug ) ]
pub struct TestsProperties
struct TestsProperties
{
#[ former( default = true ) ]
dry : bool,
Expand Down
3 changes: 1 addition & 2 deletions module/move/willbe/src/command/workspace_renew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ mod private
use wtools::error::{ anyhow::Context, Result };
use action::WorkspaceTemplate;

// qqq: `Former` forces the struct to be public
#[ derive( Former ) ]
pub struct WorkspaceNewProperties
struct WorkspaceNewProperties
{
repository_url : String,
branches : Vec< String >,
Expand Down
19 changes: 9 additions & 10 deletions module/move/willbe/src/entity/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,15 +317,15 @@ mod private
}

#[ derive( Debug, Clone ) ]
pub struct GitThingsOptions
pub struct GitOptions
{
pub git_root : AbsolutePath,
pub items : Vec< AbsolutePath >,
pub message : String,
pub dry : bool,
}

fn perform_git_commit( o : GitThingsOptions ) -> Result< ExtendedGitReport >
fn perform_git_commit( o : GitOptions ) -> Result< ExtendedGitReport >
{
let mut report = ExtendedGitReport::default();
if o.items.is_empty() { return Ok( report ); }
Expand All @@ -352,8 +352,7 @@ mod private
pub package_name : String,
pub pack : cargo::PackOptions,
pub version_bump : version::BumpOptions,
// qqq : rename
pub git_things : GitThingsOptions,
pub git_options : GitOptions,
pub publish : cargo::PublishOptions,
pub dry : bool,
}
Expand Down Expand Up @@ -396,7 +395,7 @@ mod private
dependencies : dependencies.clone(),
dry : self.dry,
};
let git_things = GitThingsOptions
let git_options = GitOptions
{
git_root : workspace_root,
items : dependencies.iter().chain([ &crate_dir ]).map( | d | d.absolute_path().join( "Cargo.toml" ) ).collect(),
Expand All @@ -416,7 +415,7 @@ mod private
package_name : self.package.name().unwrap(),
pack,
version_bump,
git_things,
git_options,
publish,
dry : self.dry,
}
Expand All @@ -440,22 +439,22 @@ mod private
package_name: _,
mut pack,
mut version_bump,
mut git_things,
mut git_options,
mut publish,
dry,
} = instruction;
pack.dry = dry;
version_bump.dry = dry;
git_things.dry = dry;
git_options.dry = dry;
publish.dry = dry;

report.get_info = Some( cargo::pack( pack ).map_err( | e | ( report.clone(), e ) )? );
// qqq : redundant field?
report.publish_required = true;
let bump_report = version::version_bump( version_bump ).map_err( | e | ( report.clone(), e ) )?;
report.bump = Some( bump_report.clone() );
let git_root = git_things.git_root.clone();
let git = match perform_git_commit( git_things )
let git_root = git_options.git_root.clone();
let git = match perform_git_commit( git_options )
{
Ok( git ) => git,
Err( e ) =>
Expand Down
2 changes: 1 addition & 1 deletion module/move/willbe/src/entity/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ mod private
pub feature : Option< TestOptionsProgressBarFeature >,
}

// qqq : remove after Former fix
// qqq : for Petro : remove after Former fix
/// Structure for progress bar feature field
pub struct TestOptionsProgressBarFeature
{
Expand Down
5 changes: 3 additions & 2 deletions module/move/willbe/src/tool/_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub( crate ) mod private

/// Check if path has a glob.
#[ allow( dead_code ) ]
pub fn glob_is( path : &str ) -> bool
fn glob_is( path : &str ) -> bool
{
let glob_chars = "*?[{";
let mut last_char = ' ';
Expand Down Expand Up @@ -159,7 +159,8 @@ pub( crate ) mod private

crate::mod_interface!
{
protected use glob_is;
// qqq : remove this?
// protected use glob_is;
protected use canonicalize;
protected use unique_folder_name;

Expand Down
2 changes: 1 addition & 1 deletion module/move/willbe/tests/inc/action/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ pub mod test;
pub mod cicd_renew;
pub mod workspace_renew;

// qqq : for Petro : sort
// aaa : for Petro : sort
// aaa : sorted & renamed

0 comments on commit f0d3981

Please sign in to comment.