mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 12:35:59 +02:00
Remove test-bins feature.
This commit is contained in:
@ -26,7 +26,7 @@ mod git;
|
||||
mod path;
|
||||
mod shell;
|
||||
mod stream;
|
||||
mod utils;
|
||||
pub mod utils;
|
||||
|
||||
pub use crate::cli::{
|
||||
cli, create_default_context, load_plugins, run_pipeline_standalone, run_vec_of_pipelines,
|
||||
|
@ -1,5 +1,6 @@
|
||||
pub mod data;
|
||||
pub mod data_processing;
|
||||
pub mod test_bins;
|
||||
|
||||
use crate::path::canonicalize;
|
||||
use nu_errors::ShellError;
|
||||
@ -21,6 +22,7 @@ pub struct ValueResource {
|
||||
|
||||
impl ValueResource {}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ValueStructure {
|
||||
pub resources: Vec<ValueResource>,
|
||||
}
|
||||
@ -96,6 +98,7 @@ pub struct Res {
|
||||
|
||||
impl Res {}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FileStructure {
|
||||
pub resources: Vec<Res>,
|
||||
}
|
||||
|
94
crates/nu-cli/src/utils/test_bins.rs
Normal file
94
crates/nu-cli/src/utils/test_bins.rs
Normal file
@ -0,0 +1,94 @@
|
||||
use std::io::{self, BufRead, Write};
|
||||
|
||||
pub fn cococo() {
|
||||
let args: Vec<String> = args();
|
||||
|
||||
if args.len() > 1 {
|
||||
// Write back out all the arguments passed
|
||||
// if given at least 1 instead of chickens
|
||||
// speaking co co co.
|
||||
let mut arguments = args.iter();
|
||||
arguments.next();
|
||||
|
||||
for arg in arguments {
|
||||
println!("{}", &arg);
|
||||
}
|
||||
} else {
|
||||
println!("cococo");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn nonu() {
|
||||
args().iter().skip(1).for_each(|arg| print!("{}", arg));
|
||||
}
|
||||
|
||||
pub fn iecho() {
|
||||
// println! panics if stdout gets closed, whereas writeln gives us an error
|
||||
let mut stdout = io::stdout();
|
||||
let _ = args()
|
||||
.iter()
|
||||
.skip(1)
|
||||
.cycle()
|
||||
.try_for_each(|v| writeln!(stdout, "{}", v));
|
||||
}
|
||||
|
||||
pub fn fail() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
pub fn chop() {
|
||||
if did_chop_arguments() {
|
||||
// we are done and don't care about standard input.
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
// if no arguments given, chop from standard input and exit.
|
||||
let stdin = io::stdin();
|
||||
let mut stdout = io::stdout();
|
||||
|
||||
for line in stdin.lock().lines() {
|
||||
if let Ok(given) = line {
|
||||
let chopped = if given.is_empty() {
|
||||
&given
|
||||
} else {
|
||||
let to = given.len() - 1;
|
||||
&given[..to]
|
||||
};
|
||||
|
||||
if let Err(_e) = writeln!(stdout, "{}", chopped) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn did_chop_arguments() -> bool {
|
||||
let args: Vec<String> = args();
|
||||
|
||||
if args.len() > 1 {
|
||||
let mut arguments = args.iter();
|
||||
arguments.next();
|
||||
|
||||
for arg in arguments {
|
||||
let chopped = if arg.is_empty() {
|
||||
&arg
|
||||
} else {
|
||||
let to = arg.len() - 1;
|
||||
&arg[..to]
|
||||
};
|
||||
|
||||
println!("{}", chopped);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
fn args() -> Vec<String> {
|
||||
// skip (--testbin bin_name args)
|
||||
std::env::args().skip(2).collect()
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
use std::io::{self, BufRead, Write};
|
||||
|
||||
fn main() {
|
||||
if did_chop_arguments() {
|
||||
// we are done and don't care about standard input.
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
// if no arguments given, chop from standard input and exit.
|
||||
let stdin = io::stdin();
|
||||
let mut stdout = io::stdout();
|
||||
for line in stdin.lock().lines() {
|
||||
if let Ok(given) = line {
|
||||
if let Err(_e) = writeln!(stdout, "{}", chop(&given)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
fn chop(word: &str) -> &str {
|
||||
if word.is_empty() {
|
||||
word
|
||||
} else {
|
||||
let to = word.len() - 1;
|
||||
&word[..to]
|
||||
}
|
||||
}
|
||||
|
||||
fn did_chop_arguments() -> bool {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() > 1 {
|
||||
let mut arguments = args.iter();
|
||||
arguments.next();
|
||||
|
||||
for arg in arguments {
|
||||
println!("{}", chop(arg));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
false
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
if args.len() > 1 {
|
||||
// Write back out all the arguments passed
|
||||
// if given at least 1 instead of chickens
|
||||
// speaking co co co.
|
||||
let mut arguments = args.iter();
|
||||
arguments.next();
|
||||
|
||||
for arg in arguments {
|
||||
println!("{}", &arg);
|
||||
}
|
||||
} else {
|
||||
println!("cococo");
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
std::process::exit(1);
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
use std::io::{self, Write};
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = std::env::args().collect();
|
||||
|
||||
// println! panics if stdout gets closed, whereas writeln gives us an error
|
||||
let mut stdout = io::stdout();
|
||||
let _ = args
|
||||
.iter()
|
||||
.skip(1)
|
||||
.cycle()
|
||||
.try_for_each(|v| writeln!(stdout, "{}", v));
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
fn main() {
|
||||
std::env::args().skip(1).for_each(|arg| print!("{}", arg));
|
||||
}
|
Reference in New Issue
Block a user