#toml #yaml #json #命令输出 #解析器 #转换 #日期

bin+lib rjc

rjc 将许多命令、文件类型和字符串的输出转换为 JSON、YAML 或 TOML

5 个版本

0.2.3 2023 年 8 月 2 日
0.2.2 2023 年 7 月 18 日
0.1.1 2023 年 7 月 11 日

#2042解析实现

40 每月下载次数

MPL-2.0 许可证

115KB
2.5K SLoC

rjc

dir | rjc dir
{"meta":{"drive":"F","serial":"38EC-3395","directory":"F:\\Dev\\rjc","files":3,"directories":4},"resources":[{"date":"01/15/2023","time":"04:14 PM","is_dir":true,"size":null,"name":"."},{"date":"01/15/2023","time":"04:14 PM","is_dir":true,"size":null,"name":".."},{"date":"01/14/2023","time":"04:25 PM","is_dir":false,"size":8,"name":".gitignore"},{"date":"01/15/2023","time":"10:38 PM","is_dir":false,"size":11117,"name":"Cargo.lock"},{"date":"01/20/2023","time":"12:53 AM","is_dir":false,"size":437,"name":"Cargo.toml"},{"date":"01/21/2023","time":"02:18 PM","is_dir":true,"size":null,"name":"src"},{"date":"01/20/2023","time":"12:53 AM","is_dir":true,"size":null,"name":"target"}]}

安装

Cargo Install (MacOS, Linux, Windows)

cargo install rjc

二进制文件

对于预编译的二进制文件,请检查本仓库中的 版本

rjc 也可以作为库使用。

use rjc::win32::dir::{DirData, parse};
use std::process::Command;

fn main() {
    let output = Command::new("cmd").args(["/C", "dir"]).output().expect("Failed to execute process.");

    let dir_data: DirData = parse(Some(String::from_utf8_lossy(&output.stdout).to_string()));

    println!("{}", dir_data.meta.drive);
}

解析器

Win32

命令 文档
assoc details
dir details
netstat details
tasklist details

Unix

命令 文档
acpi details
arp details
chage details
cksum details
date details
du details
env details
file details
ls details
passwd details
time details
timedatectl details
shadow details
sysctl details
w details
wc details

Darwin

命令 文档
airport details

外部

命令 文档
lsd details
ping details

格式

命令 文档
email-address details
timestamp details
version details

依赖项

~7MB
~116K SLoC