Skip to main content

plot/lib/core/
job_presets.rs

1use std::path::PathBuf;
2
3use crate::lib::schema::{
4	SharedJobAttributeToSelect,
5	SharedJobOptForAttrItem,
6	SharedJobOptForAttrSize,
7	SharedJobPart,
8	SharedJobRunMode,
9	SharedJobStringMode,
10};
11
12// ░░░░░░░░░░░░░░░░░░░░ ŚRODOWISKO I ŚCIEŻKI ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
13
14/// Zwraca bezwzględną ścieżkę, z której uruchomiono program (CWD).
15pub fn execution_dir() -> PathBuf {
16	std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")).canonicalize().unwrap_or_else(|_| PathBuf::from("."))
17}
18
19/// Zwraca domyślną ścieżkę do pliku konfiguracyjnego:
20/// <CWD>/target/.cargo-plot/task/CargoPlot.toml
21pub fn default_config_path() -> PathBuf {
22	execution_dir().join("target").join(".cargo-plot").join("tasks").join("CargoPlot.toml")
23}
24
25/// Domyślna zawartość nowo tworzonego pliku konfiguracyjnego TOML
26pub const TOML_DEFAULT_MINIMAL: &str = r#"
27[[job]]
28id = "a1"
29description = "default job"
30"#;
31
32// ░░░░░░░░░░░░░░░░░░░░ 【run_mode】 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
33
34pub fn default_run_modes() -> Vec<SharedJobRunMode> { vec![SharedJobRunMode::Save, SharedJobRunMode::PrintOnlyWarning] }
35
36// ░░░░░░░░░░░░░░░░░░░░ 【explorer】 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
37
38pub fn default_workspace_dir() -> PathBuf { PathBuf::from(".") }
39
40pub const DEFAULT_IGNORE_CASE: bool = false;
41
42pub fn default_explorer_patterns() -> Vec<String> {
43	vec![
44		"./{.rustfmt,Cargo,rust-toolchain,Makefile}.toml&/".into(),
45		"./**/*.rs&/".into(),
46		"!./target/**".into(),
47		"!./.git/**".into(),
48		"./.{gitattributes,gitignore}".into(),
49		"./.github/workflows/*.yml&/".into(),
50		"./.vscode/settings.json&/".into(),
51		"./{API, ARCHITECTURE, AUTHORS, CHANGELOG, README, ROADMAP, TODO}.md".into(),
52		"./dist/{**/*,*}.{bat,exe}&/".into(),
53	]
54}
55
56pub fn default_explorer_parts() -> Vec<SharedJobPart> { vec![SharedJobPart::MD, SharedJobPart::MF] }
57
58// ░░░░░░░░░░░░░░░░░░░░ 【export】 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
59
60pub fn default_out_dir() -> PathBuf { PathBuf::from("./target/.cargo-plot/out/") }
61
62pub const DEFAULT_TITLE: &str = "";
63pub const DEFAULT_NAME: &str = "";
64pub const DEFAULT_NAME_IS_FIRST: bool = false;
65pub const DEFAULT_SAVE_SEPARATELY: bool = false;
66
67// ░░░░░░░░░░░░░░░░░░░░ 【attributes】 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
68
69pub fn default_attributes_select() -> Vec<SharedJobAttributeToSelect> {
70	vec![
71		SharedJobAttributeToSelect::Date,
72		SharedJobAttributeToSelect::Time,
73		SharedJobAttributeToSelect::Size,
74		SharedJobAttributeToSelect::Item,
75		SharedJobAttributeToSelect::Path,
76	]
77}
78
79pub fn default_for_item() -> Vec<SharedJobOptForAttrItem> {
80	vec![
81		SharedJobOptForAttrItem::ListTree,
82		SharedJobOptForAttrItem::IconsLite,
83		SharedJobOptForAttrItem::NumListAft,
84	]
85}
86
87pub const DEFAULT_FOR_DATE: &str = "%Y W%V %u-%a";
88pub const DEFAULT_FOR_TIME: &str = "%H:%M:%S.%3f";
89pub const DEFAULT_FOR_SIZE: SharedJobOptForAttrSize = SharedJobOptForAttrSize::Decimal;
90
91// ░░░░░░░░░░░░░░░░░░░░ 【tuples】 ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
92
93pub const DEFAULT_DIR_FIRST: bool = false;
94pub const DEFAULT_SAME_NAME_DIRS_AND_FILES_NEARBY: bool = false;
95
96pub const DEFAULT_REVERSE: bool = false;
97pub const DEFAULT_MIRROR: bool = false;
98
99pub fn default_string_strategy() -> Vec<SharedJobStringMode> {
100	vec![SharedJobStringMode::AaZz, SharedJobStringMode::Num, SharedJobStringMode::Spec]
101}