#command-output #toml #yaml #json #json-parser #convert-json #command-line

bin+lib rjc

rjc converts the output of many commands, file-types, and strings to JSON, YAML, or TOML

5 releases

0.2.3 Aug 2, 2023
0.2.2 Jul 18, 2023
0.1.1 Jul 11, 2023

#2536 in Parser implementations

40 downloads per month

MPL-2.0 license

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"}]}

Installation

Cargo Install (MacOS, Linux, Windows)

cargo install rjc

Binaries

For precompiled binaries, check the releases in this repo.

Library

rjc can also be used as a library.

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);
}

Parsers

Win32

Commands Documentation
assoc details
dir details
netstat details
tasklist details

Unix

Commands Documentation
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

Commands Documentation
airport details

External

Commands Documentation
lsd details
ping details

Formats

Commands Documentation
email-address details
timestamp details
version details

Dependencies

~6.5MB
~113K SLoC