Skip to content

Commit 4bbbff4

Browse files
committed
Remove clone and download dir and lock file config
I don't see a good reason why these should be configurable and it makes it more difficult for sheldon to ever change the way it stores the data. In particular, it would be nice to use a separate lock file per profile.
1 parent ee575f3 commit 4bbbff4

28 files changed

Lines changed: 56 additions & 197 deletions

README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
- [`--config-dir <path>`](#--config-dir-path)
5252
- [`--data-dir <path>`](#--data-dir-path)
5353
- [`--config-file <path>`](#--config-file-path)
54-
- [`--lock-file <path>`](#--lock-file-path)
55-
- [`--clone-dir <path>`](#--clone-dir-path)
56-
- [`--download-dir <path>`](#--download-dir-path)
5754
- [`--profile <profile>`](#--profile-profile)
5855
- [XDG directory structure](#xdg-directory-structure)
5956
- [Completions](#completions)
@@ -350,27 +347,6 @@ this will default to `XDG_DATA_HOME/sheldon` otherwise it will default to
350347
Set the path to the config file. This defaults to `<config-dir>/plugins.toml`
351348
where `<config-dir>` is the config directory.
352349

353-
##### `--lock-file <path>`
354-
355-
*Environment variable:* `SHELDON_LOCK_FILE`
356-
357-
Set the path to the lock file. This defaults to `<data-dir>/plugins.lock` where
358-
`<data-dir>` is the data directory.
359-
360-
##### `--clone-dir <path>`
361-
362-
*Environment variable:* `SHELDON_CLONE_DIR`
363-
364-
Set the path to the directory where Git plugins will be cloned to. This defaults
365-
to `<data-dir>/repos` where `<data-dir>` is the data directory.
366-
367-
##### `--download-dir <path>`
368-
369-
*Environment variable:* `SHELDON_DOWNLOAD_DIR`
370-
371-
Set the path to the directory where non-Git plugins will be downloaded to. This
372-
defaults to `<data-dir>/repos` where `<data-dir>` is the data directory.
373-
374350
##### `--profile <profile>`
375351

376352
*Environment variable:* `SHELDON_PROFILE`

completions/sheldon.bash

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ _sheldon() {
4343

4444
case "${cmd}" in
4545
sheldon)
46-
opts="-h -V -q -v --help --version --quiet --verbose --color --home --config-dir --data-dir --config-file --lock-file --clone-dir --download-dir --profile init add edit remove lock source completions version"
46+
opts="-h -V -q -v --help --version --quiet --verbose --color --home --config-dir --data-dir --config-file --profile init add edit remove lock source completions version"
4747
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
4848
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
4949
return 0
@@ -69,18 +69,6 @@ _sheldon() {
6969
COMPREPLY=($(compgen -f "${cur}"))
7070
return 0
7171
;;
72-
--lock-file)
73-
COMPREPLY=($(compgen -f "${cur}"))
74-
return 0
75-
;;
76-
--clone-dir)
77-
COMPREPLY=($(compgen -f "${cur}"))
78-
return 0
79-
;;
80-
--download-dir)
81-
COMPREPLY=($(compgen -f "${cur}"))
82-
return 0
83-
;;
8472
--profile)
8573
COMPREPLY=($(compgen -f "${cur}"))
8674
return 0

completions/sheldon.zsh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ _sheldon() {
2020
'--config-dir=[The configuration directory]:PATH: ' \
2121
'--data-dir=[The data directory]:PATH: ' \
2222
'--config-file=[The config file]:PATH: ' \
23-
'--lock-file=[The lock file]:PATH: ' \
24-
'--clone-dir=[The directory where git sources are cloned to]:PATH: ' \
25-
'--download-dir=[The directory where remote sources are downloaded to]:PATH: ' \
2623
'--profile=[The profile used for conditional plugins]:PROFILE: ' \
2724
'-h[Print help information]' \
2825
'--help[Print help information]' \

docs/src/Command-line-interface.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -162,27 +162,6 @@ this will default to `XDG_DATA_HOME/sheldon` otherwise it will default to
162162
Set the path to the config file. This defaults to `<config-dir>/plugins.toml`
163163
where `<config-dir>` is the config directory.
164164

165-
#### `--lock-file <path>`
166-
167-
*Environment variable:* `SHELDON_LOCK_FILE`
168-
169-
Set the path to the lock file. This defaults to `<data-dir>/plugins.lock` where
170-
`<data-dir>` is the data directory.
171-
172-
#### `--clone-dir <path>`
173-
174-
*Environment variable:* `SHELDON_CLONE_DIR`
175-
176-
Set the path to the directory where Git plugins will be cloned to. This defaults
177-
to `<data-dir>/repos` where `<data-dir>` is the data directory.
178-
179-
#### `--download-dir <path>`
180-
181-
*Environment variable:* `SHELDON_DOWNLOAD_DIR`
182-
183-
Set the path to the directory where non-Git plugins will be downloaded to. This
184-
defaults to `<data-dir>/repos` where `<data-dir>` is the data directory.
185-
186165
#### `--profile <profile>`
187166

188167
*Environment variable:* `SHELDON_PROFILE`

src/cli/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ impl Opt {
6868
data_dir,
6969
config_dir,
7070
config_file,
71-
lock_file,
72-
clone_dir,
73-
download_dir,
7471
profile,
7572
command,
7673
} = raw_opt;
@@ -168,9 +165,9 @@ impl Opt {
168165
let config_dir = config_dir.unwrap_or(config_pre);
169166
let data_dir = data_dir.unwrap_or(data_pre);
170167
let config_file = config_file.unwrap_or_else(|| config_dir.join("plugins.toml"));
171-
let lock_file = lock_file.unwrap_or_else(|| data_dir.join("plugins.lock"));
172-
let clone_dir = clone_dir.unwrap_or_else(|| data_dir.join("repos"));
173-
let download_dir = download_dir.unwrap_or_else(|| data_dir.join("downloads"));
168+
let lock_file = data_dir.join("plugins.lock");
169+
let clone_dir = data_dir.join("repos");
170+
let download_dir = data_dir.join("downloads");
174171

175172
let ctx = Context {
176173
version: build::CRATE_RELEASE.to_string(),

src/cli/raw.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,6 @@ pub struct RawOpt {
4949
#[clap(long, value_name = "PATH", env = "SHELDON_CONFIG_FILE")]
5050
pub config_file: Option<PathBuf>,
5151

52-
/// The lock file.
53-
#[clap(long, value_name = "PATH", env = "SHELDON_LOCK_FILE")]
54-
pub lock_file: Option<PathBuf>,
55-
56-
/// The directory where git sources are cloned to.
57-
#[clap(long, value_name = "PATH", env = "SHELDON_CLONE_DIR")]
58-
pub clone_dir: Option<PathBuf>,
59-
60-
/// The directory where remote sources are downloaded to.
61-
#[clap(long, value_name = "PATH", env = "SHELDON_DOWNLOAD_DIR")]
62-
pub download_dir: Option<PathBuf>,
63-
6452
/// The profile used for conditional plugins.
6553
#[clap(long, value_name = "PROFILE", env = "SHELDON_PROFILE")]
6654
pub profile: Option<String>,

src/cli/testdata/raw_opt_help.golden

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ USAGE:
66
sheldon [OPTIONS] <SUBCOMMAND>
77

88
OPTIONS:
9-
-q, --quiet Suppress any informational output
10-
-v, --verbose Use verbose output
11-
--color <WHEN> Output coloring: always, auto, or never [default: auto]
12-
--config-dir <PATH> The configuration directory [env: SHELDON_CONFIG_DIR=]
13-
--data-dir <PATH> The data directory [env: SHELDON_DATA_DIR=]
14-
--config-file <PATH> The config file [env: SHELDON_CONFIG_FILE=]
15-
--lock-file <PATH> The lock file [env: SHELDON_LOCK_FILE=]
16-
--clone-dir <PATH> The directory where git sources are cloned to [env: SHELDON_CLONE_DIR=]
17-
--download-dir <PATH> The directory where remote sources are downloaded to [env: SHELDON_DOWNLOAD_DIR=]
18-
--profile <PROFILE> The profile used for conditional plugins [env: SHELDON_PROFILE=]
19-
-h, --help Print help information
20-
-V, --version Print version information
9+
-q, --quiet Suppress any informational output
10+
-v, --verbose Use verbose output
11+
--color <WHEN> Output coloring: always, auto, or never [default: auto]
12+
--config-dir <PATH> The configuration directory [env: SHELDON_CONFIG_DIR=]
13+
--data-dir <PATH> The data directory [env: SHELDON_DATA_DIR=]
14+
--config-file <PATH> The config file [env: SHELDON_CONFIG_FILE=]
15+
--profile <PROFILE> The profile used for conditional plugins [env: SHELDON_PROFILE=]
16+
-h, --help Print help information
17+
-V, --version Print version information
2118

2219
SUBCOMMANDS:
2320
init Initialize a new config file

src/cli/tests.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ fn raw_opt_no_options() {
7979
config_dir: None,
8080
data_dir: None,
8181
config_file: None,
82-
lock_file: None,
83-
clone_dir: None,
84-
download_dir: None,
8582
profile: None,
8683
command: RawCommand::Lock {
8784
update: false,
@@ -108,12 +105,6 @@ fn raw_opt_options() {
108105
"/test",
109106
"--config-file",
110107
"/plugins.toml",
111-
"--lock-file",
112-
"/test/plugins.lock",
113-
"--clone-dir",
114-
"/repos",
115-
"--download-dir",
116-
"/downloads",
117108
"--profile",
118109
"profile",
119110
"lock",
@@ -126,9 +117,6 @@ fn raw_opt_options() {
126117
config_dir: Some("/test".into()),
127118
data_dir: Some("/test".into()),
128119
config_file: Some("/plugins.toml".into()),
129-
lock_file: Some("/test/plugins.lock".into()),
130-
clone_dir: Some("/repos".into()),
131-
download_dir: Some("/downloads".into()),
132120
profile: Some("profile".into()),
133121
command: RawCommand::Lock {
134122
update: false,

src/context.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ pub struct Context {
1717
pub config_dir: PathBuf,
1818
pub data_dir: PathBuf,
1919
pub config_file: PathBuf,
20+
pub profile: Option<String>,
21+
22+
#[serde(skip)]
2023
pub lock_file: PathBuf,
24+
#[serde(skip)]
2125
pub clone_dir: PathBuf,
26+
#[serde(skip)]
2227
pub download_dir: PathBuf,
23-
pub profile: Option<String>,
2428
#[serde(skip)]
2529
pub output: Output,
2630
#[serde(skip)]

src/lock/clean.rs

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ use crate::lock::LockedConfig;
1212
impl LockedConfig {
1313
/// Clean the clone and download directories.
1414
pub fn clean(&self, ctx: &Context, warnings: &mut Vec<Error>) {
15-
let clean_clone_dir = self.ctx.clone_dir().starts_with(self.ctx.data_dir());
16-
let clean_download_dir = self.ctx.download_dir().starts_with(self.ctx.data_dir());
17-
18-
if !clean_clone_dir && !clean_download_dir {
19-
return;
20-
}
21-
2215
// Track the source directories, all the plugin directory parents, and all the
2316
// plugin files.
2417
let mut source_dirs = HashSet::new();
@@ -41,31 +34,27 @@ impl LockedConfig {
4134
parent_dirs.insert(self.ctx.clone_dir());
4235
parent_dirs.insert(self.ctx.download_dir());
4336

44-
if clean_clone_dir {
45-
for entry in WalkDir::new(self.ctx.clone_dir())
46-
.into_iter()
47-
.filter_entry(|e| !source_dirs.contains(e.path()))
48-
.filter_map(result::Result::ok)
49-
.filter(|e| !parent_dirs.contains(e.path()))
50-
{
51-
if let Err(err) = remove_path(ctx, entry.path()) {
52-
warnings.push(err);
53-
}
37+
for entry in WalkDir::new(self.ctx.clone_dir())
38+
.into_iter()
39+
.filter_entry(|e| !source_dirs.contains(e.path()))
40+
.filter_map(result::Result::ok)
41+
.filter(|e| !parent_dirs.contains(e.path()))
42+
{
43+
if let Err(err) = remove_path(ctx, entry.path()) {
44+
warnings.push(err);
5445
}
5546
}
5647

57-
if clean_download_dir {
58-
for entry in WalkDir::new(self.ctx.download_dir())
59-
.into_iter()
60-
.filter_map(result::Result::ok)
61-
.filter(|e| {
62-
let p = e.path();
63-
!files.contains(p) && !parent_dirs.contains(p)
64-
})
65-
{
66-
if let Err(err) = remove_path(ctx, entry.path()) {
67-
warnings.push(err);
68-
}
48+
for entry in WalkDir::new(self.ctx.download_dir())
49+
.into_iter()
50+
.filter_map(result::Result::ok)
51+
.filter(|e| {
52+
let p = e.path();
53+
!files.contains(p) && !parent_dirs.contains(p)
54+
})
55+
{
56+
if let Err(err) = remove_path(ctx, entry.path()) {
57+
warnings.push(err);
6958
}
7059
}
7160
}

0 commit comments

Comments
 (0)