Make etcetera buildable as module

This commit is contained in:
David Tolnay 2025-03-02 21:57:57 -08:00
parent 0d6c07747b
commit 6a2b06f3be
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
15 changed files with 37 additions and 108 deletions

104
Cargo.lock generated
View file

@ -197,10 +197,10 @@ version = "1.0.100"
dependencies = [
"bat",
"cargo-subcommand-metadata",
"cfg-if",
"clap",
"clap-cargo",
"console",
"etcetera",
"fs-err",
"home",
"prettyplease",
@ -215,6 +215,7 @@ dependencies = [
"termcolor",
"toml",
"toolchain_find",
"windows-sys 0.59.0",
]
[[package]]
@ -411,17 +412,6 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "etcetera"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "136d1b5283a1ab77bd9257427ffd09d8667ced0570b6f938942bc7568ed5b943"
dependencies = [
"cfg-if",
"home",
"windows-sys 0.48.0",
]
[[package]]
name = "fancy-regex"
version = "0.11.0"
@ -1112,7 +1102,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132"
dependencies = [
"windows-core",
"windows-targets 0.52.6",
"windows-targets",
]
[[package]]
@ -1124,7 +1114,7 @@ dependencies = [
"windows-implement",
"windows-interface",
"windows-result",
"windows-targets 0.52.6",
"windows-targets",
]
[[package]]
@ -1155,16 +1145,7 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.48.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
dependencies = [
"windows-targets 0.48.5",
"windows-targets",
]
[[package]]
@ -1173,7 +1154,7 @@ version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets 0.52.6",
"windows-targets",
]
[[package]]
@ -1182,22 +1163,7 @@ version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm 0.48.5",
"windows_aarch64_msvc 0.48.5",
"windows_i686_gnu 0.48.5",
"windows_i686_msvc 0.48.5",
"windows_x86_64_gnu 0.48.5",
"windows_x86_64_gnullvm 0.48.5",
"windows_x86_64_msvc 0.48.5",
"windows-targets",
]
[[package]]
@ -1206,46 +1172,28 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm 0.52.6",
"windows_aarch64_msvc 0.52.6",
"windows_i686_gnu 0.52.6",
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc 0.52.6",
"windows_x86_64_gnu 0.52.6",
"windows_x86_64_gnullvm 0.52.6",
"windows_x86_64_msvc 0.52.6",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
@ -1258,48 +1206,24 @@ version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"

View file

@ -19,10 +19,10 @@ prettyplease = []
[dependencies]
bat = { version = "0.25", default-features = false, features = ["paging", "regex-fancy"] }
cargo-subcommand-metadata = "0.1"
cfg-if = "1"
clap = { version = "4", features = ["deprecated", "derive"] }
clap-cargo = "0.15"
console = "0.15"
etcetera = "0.8"
fs-err = "3"
home = "0.5"
prettyplease = { version = "0.2.29", features = ["verbatim"] }
@ -38,6 +38,9 @@ termcolor = "1.0"
toml = "0.8"
toolchain_find = "0.4"
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_System_Com", "Win32_UI_Shell"] }
[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

View file

@ -1,5 +1,5 @@
use crate::error::Result;
use etcetera::BaseStrategy as _;
use crate::etcetera::{self, BaseStrategy as _};
use std::env;
use std::path::PathBuf;
use std::str;

View file

@ -1,3 +1,4 @@
use crate::etcetera;
use std::error::Error as StdError;
use std::fmt::{self, Display};
use std::io;

View file

@ -4,7 +4,7 @@ use std::ffi::OsStr;
use std::path::Path;
use std::path::PathBuf;
use crate::HomeDirError;
use crate::etcetera::HomeDirError;
/// The arguments to the creator method of an [`AppStrategy`](trait.AppStrategy.html).
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]

View file

@ -1,5 +1,5 @@
use crate::base_strategy::BaseStrategy;
use crate::{base_strategy, HomeDirError};
use crate::etcetera::base_strategy::BaseStrategy;
use crate::etcetera::{base_strategy, HomeDirError};
use std::path::{Path, PathBuf};
/// This is the strategy created by Apple for use on macOS and iOS devices. It is always used by GUI apps on macOS, and is sometimes used by command-line applications there too. iOS only has GUIs, so all iOS applications follow this strategy. The specification is available [here](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1).

View file

@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};
use crate::HomeDirError;
use crate::etcetera::HomeDirError;
/// This strategy has no standard or official specification. It has arisen over time through hundreds of Unixy tools. Vim and Cargo are notable examples whose configuration/data/cache directory layouts are similar to those created by this strategy.
///
@ -54,7 +54,7 @@ impl Unix {
/// Create a new Unix AppStrategy
pub fn new(args: super::AppStrategyArgs) -> Result<Self, HomeDirError> {
Ok(Self {
home_dir: crate::home_dir()?,
home_dir: crate::etcetera::home_dir()?,
unixy_name: format!(".{}", args.unixy_name()),
})
}

View file

@ -1,5 +1,5 @@
use crate::base_strategy::BaseStrategy;
use crate::{base_strategy, HomeDirError};
use crate::etcetera::base_strategy::BaseStrategy;
use crate::etcetera::{base_strategy, HomeDirError};
use std::path::{Path, PathBuf};
/// This strategy follows Windows’ conventions. It seems that all Windows GUI apps, and some command-line ones follow this pattern. The specification is available [here](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).

View file

@ -1,5 +1,5 @@
use crate::base_strategy::BaseStrategy;
use crate::{base_strategy, HomeDirError};
use crate::etcetera::base_strategy::BaseStrategy;
use crate::etcetera::{base_strategy, HomeDirError};
use std::path::{Path, PathBuf};
/// This strategy implements the [XDG Base Directories Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). It is the most common on Linux, but is increasingly being adopted elsewhere.

View file

@ -1,6 +1,6 @@
//! These strategies simply provide the user’s configuration, data, and cache directories, without knowing about the application specifically.
use crate::HomeDirError;
use crate::etcetera::HomeDirError;
use std::path::{Path, PathBuf};
/// Provides configuration, data, and cache directories of the current user.

View file

@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};
use crate::HomeDirError;
use crate::etcetera::HomeDirError;
/// This is the strategy created by Apple for use on macOS and iOS devices. It is always used by GUI apps on macOS, and is sometimes used by command-line applications there too. iOS only has GUIs, so all iOS applications follow this strategy. The specification is available [here](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html#//apple_ref/doc/uid/TP40010672-CH2-SW1).
///
@ -46,7 +46,7 @@ impl Apple {
/// Create a new Apple BaseStrategy
pub fn new() -> Result<Self, HomeDirError> {
Ok(Self {
home_dir: crate::home_dir()?,
home_dir: crate::etcetera::home_dir()?,
})
}
}

View file

@ -1,6 +1,6 @@
use std::path::{Path, PathBuf};
use crate::HomeDirError;
use crate::etcetera::HomeDirError;
/// This strategy follows Windows’ conventions. It seems that all Windows GUI apps, and some command-line ones follow this pattern. The specification is available [here](https://docs.microsoft.com/en-us/windows/win32/shell/knownfolderid).
///
@ -112,7 +112,7 @@ impl Windows {
/// Create a new Windows BaseStrategy
pub fn new() -> Result<Self, HomeDirError> {
Ok(Self {
home_dir: crate::home_dir()?,
home_dir: crate::etcetera::home_dir()?,
})
}

View file

@ -1,7 +1,7 @@
use std::path::Path;
use std::path::PathBuf;
use crate::HomeDirError;
use crate::etcetera::HomeDirError;
/// This strategy implements the [XDG Base Directories Specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). It is the most common on Linux, but is increasingly being adopted elsewhere.
///
@ -162,7 +162,7 @@ impl Xdg {
/// Create a new Xdg BaseStrategy
pub fn new() -> Result<Self, HomeDirError> {
Ok(Self {
home_dir: crate::home_dir()?,
home_dir: crate::etcetera::home_dir()?,
})
}

View file

@ -21,6 +21,7 @@ mod cmd;
mod config;
mod edit;
mod error;
mod etcetera;
mod fmt;
mod manifest;
mod opts;