-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
db.rs
127 lines (122 loc) · 4.08 KB
/
db.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
use std::collections::BTreeMap;
use crate::model::asset_name::AssetName;
use crate::model::tool::{ToolInfo, ToolInfoTag};
/// Get info about known tools from a hardcoded database
pub fn lookup_tool(tool_name: &str) -> Option<ToolInfo> {
let mut known_db = build_db();
known_db.remove(tool_name)
}
pub fn build_db() -> BTreeMap<String, ToolInfo> {
let mut tools: BTreeMap<String, ToolInfo> = BTreeMap::new();
tools.insert(
"bat".into(),
ToolInfo {
owner: "sharkdp".to_string(),
repo: "bat".to_string(),
exe_name: "bat".to_string(),
asset_name: AssetName {
linux: Some("x86_64-unknown-linux-musl".to_string()),
macos: Some("x86_64-apple-darwin".to_string()),
windows: Some("x86_64-pc-windows-msvc".to_string()),
},
tag: ToolInfoTag::Latest,
},
);
tools.insert(
"difftastic".into(),
ToolInfo {
owner: "Wilfred".to_string(),
repo: "difftastic".to_string(),
exe_name: "difft".to_string(),
asset_name: AssetName {
linux: Some("x86_64-unknown-linux-gnu".to_string()),
macos: Some("x86_64-apple-darwin".to_string()),
windows: Some("x86_64-pc-windows-msvc".to_string()),
},
tag: ToolInfoTag::Latest,
},
);
tools.insert(
"exa".into(),
ToolInfo {
owner: "ogham".to_string(),
repo: "exa".to_string(),
exe_name: "exa".to_string(),
asset_name: AssetName {
linux: Some("linux-x86_64-musl".to_string()),
macos: Some("macos-x86_64".to_string()),
windows: None,
},
tag: ToolInfoTag::Latest,
},
);
tools.insert(
"fd".into(),
ToolInfo {
owner: "sharkdp".to_string(),
repo: "fd".to_string(),
exe_name: "fd".to_string(),
asset_name: AssetName {
linux: Some("x86_64-unknown-linux-musl".to_string()),
macos: Some("x86_64-apple-darwin".to_string()),
windows: Some("x86_64-pc-windows-msvc".to_string()),
},
tag: ToolInfoTag::Latest,
},
);
tools.insert(
"ripgrep".into(),
ToolInfo {
owner: "BurntSushi".to_string(),
repo: "ripgrep".to_string(),
exe_name: "rg".to_string(),
asset_name: AssetName {
linux: Some("unknown-linux-musl".to_string()),
macos: Some("apple-darwin".to_string()),
windows: Some("x86_64-pc-windows-msvc".to_string()),
},
tag: ToolInfoTag::Latest,
},
);
tools.insert(
"tool-sync".into(),
ToolInfo {
owner: "chshersh".to_string(),
repo: "tool-sync".to_string(),
exe_name: "tool".to_string(),
asset_name: AssetName {
linux: Some("x86_64-unknown-linux-gnu".to_string()),
macos: Some("x86_64-apple-darwin".to_string()),
windows: Some("x86_64-pc-windows-msvc".to_string()),
},
tag: ToolInfoTag::Latest,
},
);
// tools.insert("tokei", ToolInfo {
// owner: "XAMPPRocky".to_string(),
// repo: "tokei".to_string(),
// exe_name: "tokei".to_string(),
// asset_name: AssetName {
// linux: Some("x86_64-unknown-linux-musl".to_string()),
// macos: Some("apple-darwin".to_string()),
// windows: Some("x86_64-pc-windows-msvc".to_string()),
// }
// tag: ToolInfoTag::Latest,
// }));
//
tools
}
/// Format tool names of the database using a mutating formatting function
/// The result is something like this (depending on a function)
///
/// ```toml
/// # [bat]
/// # [exa]
/// ```
pub fn fmt_tool_names<F: FnMut(&String) -> String>(fmt_tool: F) -> String {
build_db()
.keys()
.map(fmt_tool)
.collect::<Vec<String>>()
.join("\n")
}