Skip to content

Commit

Permalink
tilde expansions
Browse files Browse the repository at this point in the history
  • Loading branch information
geremachek committed May 20, 2021
1 parent c0cb12c commit 70e178c
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 2 deletions.
101 changes: 101 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
shellexpand = "2.1"

[dependencies.clap]
version = "2.33.3"
default-features = false
Expand Down
6 changes: 4 additions & 2 deletions src/plane/plane_commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// commands relating to the plane structure

extern crate shellexpand;

use super::Plane;
use std::{fs::File, io::{BufRead, BufReader}};
use crate::{volume::Volume, commands::MerlinError, nomen::Nomen};
Expand All @@ -23,7 +25,7 @@ impl Plane {
// open a new file

pub fn summon(&mut self, path: String) -> Result<(), MerlinError> {
Ok(self.push_volume(Volume::from_file(path)?))
Ok(self.push_volume(Volume::from_file(shellexpand::tilde(&path).to_string())?))
}

// close a file / buffer
Expand Down Expand Up @@ -71,7 +73,7 @@ impl Plane {
// read a file an parse its contents

pub fn spellbook(&mut self, file_path: &str) -> Result<(), MerlinError> {
match File::open(file_path) {
match File::open(&shellexpand::tilde(file_path).to_string()) {
Ok(file) => {
let reader = BufReader::new(file);

Expand Down
Empty file removed src/volume/command.rs
Empty file.

0 comments on commit 70e178c

Please sign in to comment.