$ rustup default nightly
$ cargo install voila
# 删除创建日期在 2020年1月1日 之后的所有文件
$ voila ./backup "@creation=date >= 2020-01-01 { print(@name has been deleted) delete(@path) }"
# 删除文件名以 2020 结束的文件
$ voila ./backup "@name ~= #(.*)-2020# { print(@name has been deleted) delete(@path) }"
$ voila DIRECTORY "<@VARIABLE | STRING | /REGEXP/> OPERATOR <@VARIABLE | STRING | #REGEXP#> [|| | && ANOTHER_CONDITIONAL ...] {OPERATION1-CYCLE-1(ARG1 ARG1, ARG2) OPERATION2-CYCLE-1(ARG1 ARG2) ...; OPERATION1-CYCLE-2(ARG1, ARG2 ARG2, ARG3)...}"
use peekread::{PeekRead, SeekPeekReader};
let mut f = SeekPeekReader::new(File::open("ambiguous")?);
// HTML is so permissive its parser never fails, so check for signature.
if f.starts_with("<!DOCTYPE") {
Ok(ParseResult::Html(parse_as_html(f)))
} else {
// Can pass PeekCursor to functions accepting T: Read without them
// having to be aware of peekread.
parse_as_jpg(f.peek()).map(ParseResult::Jpg)
.or_else(|_| parse_as_png(f.peek()).map(ParseResult::Png))
.or_else(|_| parse_as_gif(f.peek()).map(ParseResult::Gif))
.or_else(|_| parse_as_javascript(f.peek()).map(ParseResult::Js))
}
$ cargo run --bin sql-rs -- -s test-files/seed.sql
...
> select * from users;
> select u.email, a.* from users as u join addresses as a on u.id = a.user_id where u.age > 22 and a.type = 'mail';
> select * from users as u left join addresses as a on false;
> select * from users as u right join addresses as a on false;
> select * from users order by age desc;
> select * from addresses order by street1 limit 2;
> select count(*) from addresses;
> update users set age = 22 where id = '1';
$ ps -F -C bustd
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
vrmiguel 353609 187407 5 151 8 2 01:20 pts/2 00:00:00 target/x86_64-unknown-linux-musl/release/bustd -V -n
$ ps -F -C earlyoom
UID PID PPID C SZ RSS PSR STIME TTY TIME CMD
vrmiguel 350497 9498 0 597 688 6 01:12 pts/1 00:00:00 ./earlyoom/
upsc username@localhost ups.status
// 支持的 print
Type { a: "a", b: [0, 1], c: {"So": "pretty"} }
// 骚气的 print
🌈 🌈
Type { ⭐
⭐ a: "a", ⭐
⭐ b: [ 🌟
0,
⭐ 1, ⭐
⭐ ], ⭐
c: {
⭐ "So": "pretty",
⭐ },
} ⭐
🌈 🌈
use prettier_print::prettier_printer::PrettierPrinter;
use prettier_print::sparkles::Sparkles;
use std::collections::HashMap;
use std::io::stdout;
fn main() {
#[derive(Debug)]
struct Type {
a: String,
b: Vec<i32>,
c: HashMap<&'static str, &'static str>,
}
let input = Type {
a: "a".to_string(),
b: vec![0, 1],
c: {
let mut map = HashMap::new();
map.insert("So", "pretty");
map
},
};
println!("{:?}", &input);
println!("{}", PrettierPrinter::default().print(&input));
}
From 日报小组 长琴
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。