Skip to content

Commit

Permalink
Update default root directory and clone directory
Browse files Browse the repository at this point in the history
- The root directory now defaults to `{home}/.sheldon`.
- The clone directory now defaults to `{root}/repos`.
  • Loading branch information
rossmacarthur committed Apr 29, 2020
1 parent 75a39b3 commit 1845483
Show file tree
Hide file tree
Showing 16 changed files with 68 additions and 68 deletions.
21 changes: 11 additions & 10 deletions README.md
Expand Up @@ -106,12 +106,12 @@ cargo install sheldon --force
## Getting started

The config file uses the [TOML] file format. Create a configuration file at
`~/.zsh/plugins.toml` and add details for your first plugin by adding a unique
key to the `plugins` table. In the example configuration file below we add a new
Github type plugin with a unique name `oh-my-zsh`.
`~/.sheldon/plugins.toml` and add details for your first plugin by adding a
unique key to the `plugins` table. In the example configuration file below we
add a new Github type plugin with a unique name `oh-my-zsh`.

```toml
# ~/.zsh/plugins.toml
# ~/.sheldon/plugins.toml

# ┌─ Unique name for the plugin
# ┌───┴───┐
Expand Down Expand Up @@ -188,10 +188,10 @@ The output of this command is highly configurable. You can define your own
| Option | Environment variable | Description |
| ----------------------- | ---------------------- | ----------------------------------------------------------- |
| `--home <path>` | `HOME` | Set the home directory. |
| `--root <path>` | `SHELDON_ROOT` | Set the root directory. (*default:* `<home>/.zsh`) |
| `--root <path>` | `SHELDON_ROOT` | Set the root directory. (*default:* `<home>/.sheldon`) |
| `--config-file <path>` | `SHELDON_CONFIG_FILE` | Set the config file. (*default:* `<root>/plugins.toml`) |
| `--lock-file <path>` | `SHELDON_LOCK_FILE` | Set the lock file. (*default:* `<config-file>.lock`) |
| `--clone-dir <path>` | `SHELDON_CLONE_DIR` | Set the clone directory. (*default:* `<root>/repositories`) |
| `--clone-dir <path>` | `SHELDON_CLONE_DIR` | Set the clone directory. (*default:* `<root>/repos`) |
| `--download-dir <path>` | `SHELDON_DOWNLOAD_DIR` | Set the download directory. (*default:* `<root>/downloads`) |

**Note:** in rare circumstances **sheldon** will not be able to automatically
Expand Down Expand Up @@ -299,7 +299,7 @@ current user's home directory.

```toml
[plugins.pure]
local = "~/Downloads/repositories/pure"
local = "~/Downloads/repos/pure"
```

## Configuration: plugin options
Expand Down Expand Up @@ -409,12 +409,13 @@ You can use the following global information in templates

### Example: symlinking files

Lets say we would like a template to symlink files into the `~/.zsh/functions`
directory. We could create a new template with name **function**, like this
Lets say we would like a template to symlink files into the
`~/.sheldon/functions` directory. We could create a new template with name
**function**, like this

```toml
[templates]
function = { value = 'ln -sf "{{ file }}" "~/.zsh/functions/{{ name }}"', each = true }
function = { value = 'ln -sf "{{ file }}" "~/.sheldon/functions/{{ name }}"', each = true }
```

It can then be applied to the plugin like this
Expand Down
4 changes: 2 additions & 2 deletions src/cli.rs
Expand Up @@ -293,10 +293,10 @@ impl Opt {
process::exit(1);
}
};
let root = root.unwrap_or_else(|| home.join(".zsh"));
let root = root.unwrap_or_else(|| home.join(".sheldon"));
let config_file = config_file.unwrap_or_else(|| root.join("plugins.toml"));
let lock_file = lock_file.unwrap_or_else(|| config_file.with_extension("lock"));
let clone_dir = clone_dir.unwrap_or_else(|| root.join("repositories"));
let clone_dir = clone_dir.unwrap_or_else(|| root.join("repos"));
let download_dir = download_dir.unwrap_or_else(|| root.join("downloads"));

let settings = Settings {
Expand Down
27 changes: 13 additions & 14 deletions src/lock.rs
Expand Up @@ -784,7 +784,7 @@ mod tests {
home: "/".into(),
config_file: root.join("config.toml"),
lock_file: root.join("config.lock"),
clone_dir: root.join("repositories"),
clone_dir: root.join("repos"),
download_dir: root.join("downloads"),
root: root.to_path_buf(), // must come after the joins above
},
Expand Down Expand Up @@ -1044,7 +1044,7 @@ mod tests {

assert_eq!(
locked.dir,
dir.join("repositories/github.com/rossmacarthur/sheldon-test")
dir.join("repos/github.com/rossmacarthur/sheldon-test")
);
assert_eq!(locked.file, None)
}
Expand Down Expand Up @@ -1087,7 +1087,7 @@ mod tests {
apply: None,
};
let locked_source = plugin.source.clone().lock(&ctx).unwrap();
let clone_dir = dir.join("repositories/github.com/rossmacarthur/sheldon-test");
let clone_dir = dir.join("repos/github.com/rossmacarthur/sheldon-test");

let locked = plugin
.lock(&ctx, locked_source, &[], &["hello".into()])
Expand Down Expand Up @@ -1121,7 +1121,7 @@ mod tests {
apply: None,
};
let locked_source = plugin.source.clone().lock(&ctx).unwrap();
let clone_dir = dir.join("repositories/github.com/rossmacarthur/sheldon-test");
let clone_dir = dir.join("repos/github.com/rossmacarthur/sheldon-test");

let locked = plugin
.lock(
Expand Down Expand Up @@ -1200,7 +1200,7 @@ mod tests {
let root = temp1.path();
let config_file = manifest_dir.join("docs/plugins.example.toml");
let lock_file = root.join("plugins.lock");
let clone_dir = root.join("repositories");
let clone_dir = root.join("repos");
let download_dir = root.join("downloads");
let ctx = Context {
settings: Settings {
Expand Down Expand Up @@ -1240,16 +1240,16 @@ mod tests {
vec![
LockedPlugin::External(LockedExternalPlugin {
name: "async".to_string(),
source_dir: root.join("repositories/github.com/mafredri/zsh-async"),
source_dir: root.join("repos/github.com/mafredri/zsh-async"),
plugin_dir: None,
files: vec![root.join("repositories/github.com/mafredri/zsh-async/async.zsh")],
files: vec![root.join("repos/github.com/mafredri/zsh-async/async.zsh")],
apply: vec_into!["function"]
}),
LockedPlugin::External(LockedExternalPlugin {
name: "pure".to_string(),
source_dir: root.join("repositories/github.com/sindresorhus/pure"),
source_dir: root.join("repos/github.com/sindresorhus/pure"),
plugin_dir: None,
files: vec![root.join("repositories/github.com/sindresorhus/pure/pure.zsh")],
files: vec![root.join("repos/github.com/sindresorhus/pure/pure.zsh")],
apply: vec_into!["prompt"]
}),
LockedPlugin::External(LockedExternalPlugin {
Expand All @@ -1275,11 +1275,10 @@ ip_netns_prompt_info() {
}),
LockedPlugin::External(LockedExternalPlugin {
name: "docker-destroy-all".to_string(),
source_dir: root.join("repositories/gist.github.com/79ee61f7c140c63d2786"),
source_dir: root.join("repos/gist.github.com/79ee61f7c140c63d2786"),
plugin_dir: None,
files: vec![root.join(
"repositories/gist.github.com/79ee61f7c140c63d2786/get_last_pane_path.sh"
)],
files: vec![root
.join("repos/gist.github.com/79ee61f7c140c63d2786/get_last_pane_path.sh")],
apply: vec_into!["PATH"]
})
]
Expand Down Expand Up @@ -1356,7 +1355,7 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"
plugins = []
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/clean
Expand Up @@ -6,7 +6,7 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"
plugins = []

Expand All @@ -16,7 +16,7 @@ plugins = []

# lock.stderr
[LOADED] ~/plugins.toml
[REMOVED] ~/repositories/test.com
[REMOVED] ~/repos/test.com
[LOCKED] ~/plugins.lock

# source.stdout
Expand Down
4 changes: 2 additions & 2 deletions tests/cases/clean_permission_denied
Expand Up @@ -6,7 +6,7 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"
plugins = []

Expand All @@ -18,7 +18,7 @@ plugins = []
[LOADED] ~/plugins.toml
[LOCKED] ~/plugins.lock

[WARNING] failed to remove directory `~/repositories/test.com`
[WARNING] failed to remove directory `~/repos/test.com`
due to: Permission denied (os error 13)

# source.stdout
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/empty
Expand Up @@ -6,7 +6,7 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"
plugins = []

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/github_bad_url
Expand Up @@ -16,7 +16,7 @@ github = "rossmacarthur/sheldon-bad-url"
due to: remote authentication required but none available

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"

# source.stderr
[LOADED] ~/plugins.toml
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/github_branch
Expand Up @@ -9,13 +9,13 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"

[[plugins]]
name = "test"
source_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
source_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
apply = ["source"]

[templates]
Expand All @@ -28,7 +28,7 @@ apply = ["source"]
[LOCKED] ~/plugins.lock

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"

# source.stderr
[UNLOCKED] ~/plugins.lock
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/github_git
Expand Up @@ -9,13 +9,13 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"

[[plugins]]
name = "test"
source_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
source_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
apply = ["source"]

[templates]
Expand All @@ -28,7 +28,7 @@ apply = ["source"]
[LOCKED] ~/plugins.lock

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"

# source.stderr
[UNLOCKED] ~/plugins.lock
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/github_https
Expand Up @@ -8,13 +8,13 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"

[[plugins]]
name = "test"
source_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
source_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
apply = ["source"]

[templates]
Expand All @@ -27,7 +27,7 @@ apply = ["source"]
[LOCKED] ~/plugins.lock

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"

# source.stderr
[UNLOCKED] ~/plugins.lock
Expand Down
10 changes: 5 additions & 5 deletions tests/cases/github_submodule
Expand Up @@ -10,14 +10,14 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"

[[plugins]]
name = "test"
source_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test"
plugin_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test/self/self"
files = ["<root>/repositories/github.com/rossmacarthur/sheldon-test/self/self/test.plugin.zsh"]
source_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test"
plugin_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test/self/self"
files = ["<root>/repos/github.com/rossmacarthur/sheldon-test/self/self/test.plugin.zsh"]
apply = ["source"]

[templates]
Expand All @@ -30,7 +30,7 @@ apply = ["source"]
[LOCKED] ~/plugins.lock

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/self/self/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/self/self/test.plugin.zsh"

# source.stderr
[UNLOCKED] ~/plugins.lock
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/github_tag
Expand Up @@ -9,13 +9,13 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"

[[plugins]]
name = "test"
source_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
source_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
apply = ["source"]

[templates]
Expand All @@ -28,7 +28,7 @@ apply = ["source"]
[LOCKED] ~/plugins.lock

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"

# source.stderr
[UNLOCKED] ~/plugins.lock
Expand Down
8 changes: 4 additions & 4 deletions tests/cases/inline
Expand Up @@ -13,13 +13,13 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/plugins.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"

[[plugins]]
name = "test"
source_dir = "<root>/repositories/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
source_dir = "<root>/repos/github.com/rossmacarthur/sheldon-test"
files = ["<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"]
apply = ["source"]

[[plugins]]
Expand All @@ -36,7 +36,7 @@ raw = "echo 'testing...'\n"
[LOCKED] ~/plugins.lock

# source.stdout
source "<root>/repositories/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
source "<root>/repos/github.com/rossmacarthur/sheldon-test/test.plugin.zsh"
echo 'testing...'


Expand Down
2 changes: 1 addition & 1 deletion tests/cases/override_config_file
Expand Up @@ -6,7 +6,7 @@ home = "<root>"
root = "<root>"
config_file = "<root>/test.toml"
lock_file = "<root>/test.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"
plugins = []

Expand Down
2 changes: 1 addition & 1 deletion tests/cases/override_lock_file
Expand Up @@ -6,7 +6,7 @@ home = "<root>"
root = "<root>"
config_file = "<root>/plugins.toml"
lock_file = "<root>/test.lock"
clone_dir = "<root>/repositories"
clone_dir = "<root>/repos"
download_dir = "<root>/downloads"
plugins = []

Expand Down

0 comments on commit 1845483

Please sign in to comment.