Oregami
Repositories/oxedyne/fe2o3

oxedyne/fe2o3/fe2o3_syntax/src/apps/file.rs

2.9 KiB, 15 runs

created by r1870400018:1039, which is this file's identity for as long as the history lasts, whatever it is later renamed to

download · who wrote it · its history

1use crate::{
2 Syntax,
3 arg::{
4 Arg,
5 ArgConfig,
6 },
7 cmd::{
8 Cmd,
9 CmdConfig,
10 },
11};
12
13use oxedyne_fe2o3_core::prelude::*;
14use oxedyne_fe2o3_jdat::prelude::*;
15
16pub fn generic_file_system(
17 mut s: Syntax,
18)
19 -> Outcome<Syntax>
20{
21 // ┌───────────────────────┐
22 // │ FILE SYSTEM │
23 // └───────────────────────┘
24
25 // ---------------------------------------------------------------------------------------------
26 // Command: cd
27 // ---------------------------------------------------------------------------------------------
28 let cmd = Cmd::from(CmdConfig {
29 name: fmt!("cd"),
30 help: Some(fmt!("Change directory")),
31 vals: vec![(Kind::Str, fmt!("New directory path")).into()],
32 cat: fmt!("File system"),
33 ..Default::default()
34 });
35 s = res!(s.add_cmd(cmd));
36 // =============================================================================================
37
38 // ---------------------------------------------------------------------------------------------
39 // Command: ls
40 // ---------------------------------------------------------------------------------------------
41 let mut cmd = Cmd::from(CmdConfig {
42 name: fmt!("ls"),
43 help: Some(fmt!("List directory contents")),
44 cat: fmt!("File system"),
45 ..Default::default()
46 });
47 let a1 = Arg::from(ArgConfig {
48 name: fmt!("sort"),
49 hyph1: Some(fmt!("s")),
50 vals: vec![(Kind::Str, fmt!("Sort directive 'size', 'type' or 'name'")).into()],
51 help: Some(fmt!("Sort by 'size', 'type' or 'name'")),
52 ..Default::default()
53 });
54 let a2 = Arg::from(ArgConfig {
55 name: fmt!("bytes"),
56 hyph1: Some(fmt!("b")),
57 help: Some(fmt!("Show size in bytes (otherwise humanised)")),
58 ..Default::default()
59 });
60 let a3 = Arg::from(ArgConfig {
61 name: fmt!("reverse"),
62 hyph1: Some(fmt!("r")),
63 help: Some(fmt!("Reverse any sort")),
64 ..Default::default()
65 });
66 cmd = res!(cmd.add_arg(a1));
67 cmd = res!(cmd.add_arg(a2));
68 cmd = res!(cmd.add_arg(a3));
69 s = res!(s.add_cmd(cmd));
70 // =============================================================================================
71
72 // ---------------------------------------------------------------------------------------------
73 // Command: pwd
74 // ---------------------------------------------------------------------------------------------
75 let cmd = Cmd::from(CmdConfig {
76 name: fmt!("pwd"),
77 help: Some(fmt!("Print path of current/working directory")),
78 cat: fmt!("File system"),
79 ..Default::default()
80 });
81 s = res!(s.add_cmd(cmd));
82 // =============================================================================================
83
84 Ok(s)
85}