This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 657
/
help.rs
146 lines (114 loc) · 5.74 KB
/
help.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
use rome_console::{markup, ConsoleExt, Markup};
use crate::{CliSession, Termination, VERSION};
const MAIN: Markup = markup! {
"Rome CLI v"{VERSION}"
"<Emphasis>"COMMANDS:"</Emphasis>"
- "<Emphasis>"check"</Emphasis>" Run the linter on a set of files
- "<Emphasis>"ci"</Emphasis>" Run the linter and check the formatting of a set of files
- "<Emphasis>"format"</Emphasis>" Run the formatter on a set of files
- "<Emphasis>"init"</Emphasis>" Bootstraps a new rome project
- "<Emphasis>"start"</Emphasis>" Start the Rome daemon server process
- "<Emphasis>"stop"</Emphasis>" Stop the Rome daemon server process
- "<Emphasis>"lsp-proxy"</Emphasis>" Acts as a server for the Language Server Protocol over stdin/stdout
- "<Emphasis>"rage"</Emphasis>" Prints information for debugging
- "<Emphasis>"version"</Emphasis>" Shows the Rome version information and quit
- "<Emphasis>"help"</Emphasis>" Prints this help message
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--no-colors"</Dim>" Disable the formatting of markup (print everything as plain text)
"<Dim>"--use-server"</Dim>" Connect to a running instance of the Rome daemon server
"<Dim>"--version"</Dim>" Show the Rome version information and quit
"<Dim>"--files-max-size"</Dim>" The maximum allowed size for source code files in bytes. (default: 1024)
"
};
const CHECK: Markup = markup! {
<Emphasis>"Rome Check"</Emphasis>": Run the linter on a set of files
"<Emphasis>"USAGE:"</Emphasis>"
rome check <INPUTS...>
INPUTS can be one or more filesystem path, each pointing to a single file or an entire directory to be searched recursively for supported files
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--apply"</Dim>" Apply safe fixes
"<Dim>"--apply-suggested"</Dim>" Apply safe and suggested fixes
"<Dim>"--max-diagnostics"</Dim>" Cap the amount of diagnostics displayed - default 20
"
};
const FORMAT_OPTIONS: Markup = markup! {
"
"<Dim>"--indent-style <tabs|space>"</Dim>" Change the indention character (default: tabs)
"<Dim>"--indent-size <number>"</Dim>" If the indentation style is set to spaces, determine how many spaces should be used for indentation (default: 2)
"<Dim>"--line-width <number>"</Dim>" Change how many characters the formatter is allowed to print in a single line (default: 80)
"<Dim>"--quote-style <single|double>"</Dim>" Changes the quotation character for strings (default: \")
"<Dim>"--quote-properties <as-needed|preserve>"</Dim>" Changes when properties in object should be quoted (default: as-needed)
"<Dim>"--trailing-comma <all|es5|none>"</Dim>" Changes trailing commas in multi-line comma-separated syntactic structures (default: all)
"
};
const CI: Markup = markup! {
"Rome CI: Run the linter and formatter check on a set of files
"<Emphasis>"USAGE:"</Emphasis>"
rome ci [OPTIONS] <INPUTS...>
INPUTS can be one or more filesystem path, each pointing to a single file or an entire directory to be searched recursively for supported files
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--formatter-enabled"</Dim>" Allow to enable or disable the formatter check. (default: true)
"<Dim>"--linter-enabled"</Dim>" Allow to enable or disable the linter check. (default: true)"
{FORMAT_OPTIONS}
};
const FORMAT: Markup = markup! {
"Rome Formatter
"<Emphasis>"USAGE:"</Emphasis>"
rome format [OPTIONS] <INPUTS...>
INPUTS can be one or more filesystem path, each pointing to a single file or an entire directory to be searched recursively for supported files
"<Emphasis>"OPTIONS:"</Emphasis>"
"<Dim>"--write"</Dim>" Edit the files in place (beware!) instead of printing the diff to the console
"<Dim>"--skip-errors"</Dim>" Skip over files containing syntax errors instead of emitting an error diagnostic."
{FORMAT_OPTIONS}
""<Dim>"--stdin-file-path <string>"</Dim>" A file name with its extension to pass when reading from standard in, e.g. echo 'let a;' | rome format --stdin-file-path file.js
"
};
const INIT: Markup = markup! {
"Rome init: bootstraps a new rome project"
};
const START: Markup = markup! {
"Rome start: Start the Rome daemon server process
"<Emphasis>"USAGE:"</Emphasis>"
rome start"
};
const STOP: Markup = markup! {
"Rome stop: Stop the Rome daemon server process
"<Emphasis>"USAGE:"</Emphasis>"
rome stop"
};
const START_LSP_PROXY: Markup = markup! {
"Rome lsp-proxy: Acts as a server for the Language Server Protocol over stdin/stdout
"<Emphasis>"USAGE:"</Emphasis>"
rome lsp-proxy"
};
const RAGE: Markup = markup! {
"Rome rage: Prints information for debugging
"<Emphasis>"USAGE:"</Emphasis>"
rome rage"
};
const VERSION_HELP_TEXT: Markup = markup! {
"Rome version: Show the Rome version information
"<Emphasis>"USAGE:"</Emphasis>"
rome version"
};
pub(crate) fn help(mut session: CliSession, command: Option<&str>) -> Result<(), Termination> {
let help_text = match command {
Some("help") | None => MAIN,
Some("check") => CHECK,
Some("ci") => CI,
Some("format") => FORMAT,
Some("init") => INIT,
Some("start") => START,
Some("stop") => STOP,
Some("lsp-proxy") => START_LSP_PROXY,
Some("version") => VERSION_HELP_TEXT,
Some("rage") => RAGE,
Some(cmd) => {
return Err(Termination::UnknownCommandHelp {
command: cmd.into(),
})
}
};
session.app.console.log(help_text);
Ok(())
}