1mod finalize;
2pub(crate) mod iters;
3mod to_args;
4
5#[allow(unused_imports)]
6use crate::TryFinalizeInit;
7use crate::{ArcPathBuf, GlobSetPattern, RangeUsize, Result};
8use enum_map::{Enum, EnumMap};
9use std::{
10 fs,
11 path::{Path, PathBuf},
12};
13
14#[derive(Clone, Debug, PartialEq)]
21#[non_exhaustive]
22pub struct Input {
23 pub dir: PathBuf,
24 pub range: Option<RangeUsize>,
25 pub skip: Option<GlobSetPattern>,
26 pub depth: u8,
27 pub solo: bool,
28 pub need_num: bool,
29 pub out_need_num: bool,
30 pub dirs: EnumMap<InputFileType, Vec<ArcPathBuf>>,
31}
32
33#[derive(Copy, Clone, Debug, Enum)]
35#[non_exhaustive]
36pub enum InputFileType {
37 Font,
38 Media,
39}
40
41impl Input {
42 pub(crate) const DEPTH_DEFAULT: u8 = 16;
43
44 pub(crate) fn try_default_dir() -> Result<PathBuf> {
45 Self::try_canonicalize_and_read(".")
46 }
47
48 pub(crate) fn upd_out_need_num(&mut self, need: bool) {
52 self.out_need_num = need;
53 if need {
54 self.need_num = true;
55 }
56 }
57
58 pub(crate) fn try_canonicalize_and_read(dir: impl AsRef<Path>) -> Result<PathBuf> {
64 let dir = fs::canonicalize(dir)?;
65 fs::read_dir(&dir)?;
66 Ok(dir)
67 }
68}