Skip to content

Commit

Permalink
Merge pull request #1233 from SRetip/full_string_on_dry
Browse files Browse the repository at this point in the history
READY : Full string on dry
  • Loading branch information
Wandalen committed Mar 22, 2024
2 parents 95ef442 + e80fcd5 commit 09c95c1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 41 deletions.
38 changes: 38 additions & 0 deletions module/move/wca/src/ca/grammar/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
pub( crate ) mod private
{
use crate::*;
use std::fmt::
{
Display,
Formatter
};
use wtools;
use wtools::{ error::Result, err };
use wtools::Itertools;

/// Available types that can be converted to a `Value`
///
Expand Down Expand Up @@ -87,6 +93,38 @@ pub( crate ) mod private
List( Vec< Value > ),
}

impl Display for Value
{
fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result
{
match self
{
Value::String( s ) =>
{
write!( f , "{s}" )?;
}
Value::Number( n ) =>
{
write!( f, "{n}" )?;
}
Value::Path( p ) =>
{
write!( f, "{}", p.display() )?;
}
Value::Bool( b ) =>
{
write!( f, "{b}" )?;
}
Value::List( list ) =>
{
let list = list.iter().map( | element | element.to_string() ).join( "," ); // qqq : don't hardcode ", " find way to get original separator
write!( f, "{list}" )?;
}
}
Ok( () )
}
}

macro_rules! value_into_impl
{
( $( $value_kind : path => $( $kind : ty => $cast : expr ),+ );+ ) =>
Expand Down
4 changes: 3 additions & 1 deletion module/move/willbe/src/command/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ mod private

pub fn publish( args : Args, properties : Props ) -> Result< () >
{
let args_line = format!( "{}", args.get_owned( 0 ).unwrap_or( std::path::PathBuf::from( "" ) ).display() );
let prop_line = format!( "{}", properties.iter().map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ).collect::< Vec< _ > >().join(" ") );
let patterns : Vec< _ > = args.get_owned( 0 ).unwrap_or_else( || vec![ "./".into() ] );

let dry : bool = properties
Expand All @@ -31,7 +33,7 @@ mod private

if dry && report.packages.iter().find( |( _, p )| p.publish_required ).is_some()
{
println!( "To apply plan, call the command `will .publish dry:0`" )
println!( "To apply plan, call the command `will .publish {} dry:0 {}`", args_line, prop_line )
// qqq : for Petro : for Bohdan : bad. should be exact command with exact parameters
}

Expand Down
41 changes: 1 addition & 40 deletions module/move/willbe/src/command/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,15 @@ mod private
{
Args,
Props,
Value,
};
use wtools::error::Result;
use _path::AbsolutePath;
use action::test::TestsCommandOptions;
use former::Former;
use channel::Channel;
use error_tools::for_app::bail;
use iter_tools::Itertools;
use optimization::Optimization;

trait ToString
{
fn to_string( &self ) -> String;
}


impl ToString for Value
{
fn to_string( &self ) -> String
{
match self
{
Value::String( s ) =>
{
format!( "{s}" )
}
Value::Number( n ) =>
{
format!( "{n}" )
}
Value::Path( p ) =>
{
format!( "{}", p.display() )
}
Value::Bool( b ) =>
{
format!( "{b}" )
}
Value::List( list ) =>
{
let list = list.iter().map( | element | element.to_string() ).join( ", "); // qqq : don't hardcode ", " find way to get original separator
format!( "{list}" )
}
}
}
}

#[ derive( Former, Debug ) ]
struct TestsProperties
{
Expand Down Expand Up @@ -91,7 +52,7 @@ mod private
/// run tests in specified crate
pub fn test( args : Args, properties : Props ) -> Result< () >
{
let args_line = format!( "{}", args.get_owned( 0 ).unwrap_or( "" ) );
let args_line = format!( "{}", args.get_owned( 0 ).unwrap_or( std::path::PathBuf::from( "" ) ).display() );
let prop_line = format!( "{}", properties.iter().map( | p | format!( "{}:{}", p.0, p.1.to_string() ) ).collect::< Vec< _ > >().join(" ") );
let path : PathBuf = args.get_owned( 0 ).unwrap_or_else( || "./".into() );
let path = AbsolutePath::try_from( path )?;
Expand Down

0 comments on commit 09c95c1

Please sign in to comment.