Skip to content

Commit 07e215b

Browse files
authored
Merge pull request #11 from araekiel/v0.1.2
V0.1.2
2 parents a9f9302 + 6b2e153 commit 07e215b

File tree

16 files changed

+306
-194
lines changed

16 files changed

+306
-194
lines changed

Cargo.lock

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jt"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["araekiel <kumarshashwatsri@gmail.com>"]
66
license = "MIT"
@@ -17,3 +17,4 @@ toml = "0.5.9"
1717
clap = { version = "3.2.15", features = ["derive"] }
1818
directories = "4.0.1"
1919
fs_extra = "1.2.0"
20+
dunce = "1.0.3"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Kumar Shashwat
3+
Copyright (c) 2023 Kumar Shashwat
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 71 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# *jot*
22

3-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/3786cfe55477410eacc695685338b788)](https://www.codacy.com/gh/araekiel/jot/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=araekiel/jot&amp;utm_campaign=Badge_Grade)
43
<a href="LICENSE"><img alt="Release" src="https://img.shields.io/badge/license-MIT-green"></a>
5-
<a href="https://github.com/araekiel/jot/releases/tag/v0.1.1"><img alt="Release" src="https://img.shields.io/badge/release-v0.1.1-red"></a>
6-
<a href="https://crates.io/crates/jt"><img alt="Cargo" src="https://img.shields.io/badge/cargo-jt-blue"></a>
4+
<a href="https://github.com/araekiel/jot/releases/tag/v0.1.2"><img alt="Release" src="https://img.shields.io/badge/release-v0.1.2-red"></a>
5+
<a href="https://crates.io/crates/jt"><img alt="Cargo" src="https://img.shields.io/badge/crates.io-jt-blue"></a>
76

87
<p>
98
<a href="#installation">Installation</a> •
10-
<a href="#notes">Notes</a> •
119
<a href="#usage">Usage</a> •
10+
<a href="#notes">Notes</a> •
1211
<a href="#changelog">Changelog</a> •
1312
<a href="#build-from-source">Build from Source</a> •
1413
<a href="#dependencies">Dependencies</a> •
@@ -26,11 +25,6 @@ Commands that encompass all basic needs are included. Each command has an alias
2625

2726
<img alt="Screenshot" src="assets/imgs/jot.png"/>
2827

29-
<br>
30-
31-
Jot is under active development. While it contains all basic functions that should serve most needs, there's a laundry list of features that are yet to and will be added overtime.<br>
32-
Check out [***UPDATES.md***](UPDATES.md) to see upcoming updates. ***This project is not open to contributions at the moment.***
33-
3428
## Installation
3529

3630
#### ***Install with cargo:***
@@ -41,16 +35,7 @@ $ cargo install jt
4135

4236
#### ***Use executable*** (only for windows)
4337

44-
Download [***jt.exe***](https://github.com/araekiel/jot/releases/download/v0.1.1/jt.exe) (***v0.1.1***) and add it to your path.
45-
46-
## Notes
47-
48-
- App data is stored in config and data files in locations generated by the [***directories***](https://crates.io/crates/directories) crate. Individual Vault data is stored in '***.jot***' folder inside each vault. It is advised that these files not be tampered with, since atm there's no way to automatically fix them.
49-
- App data files are generated in their default state the first time a command is run, if they don't exist already. Vault data files are generated in their default state when a vault is created.
50-
- App config has two fields: ***editor*** & ***conflict***.
51-
- ***editor*** by default is set to ***nvim*** and ***conflict*** to ***true***.
52-
- ***conflict*** field tells jot if the editor conflicts with it for control over the terminal. Set it to *true* for editors like *nvim* and *false* for editors like *notepad*.
53-
- Jot is published on ***crates.io*** as '***jt***', since 'jot' wasn't available.
38+
Download [***jt.exe***](https://github.com/araekiel/jot/releases/download/v0.1.2/jt.exe) (***v0.1.2***) and add it to your path.
5439

5540
## Usage
5641

@@ -62,7 +47,7 @@ The following example represents a general user flow when first using ***Jot***.
6247
$ jt vault newvault ~/vaults
6348
```
6449

65-
Here, ***newvault*** is the name of the vault, and '***~/vault***' is the location where it will be created (this location should be an absolute fs path and exist already or jot will throw an error).
50+
Here, ***newvault*** is the name of the vault, and '***~/vaults***' is the location where it will be created (this location should be an absolute fs path and exist already or jot will throw an error).
6651

6752
Providing no arguments to `vault` command will list all vaults.
6853

@@ -86,7 +71,7 @@ $ jt enter newvault
8671

8772
`enter` command is also used to switch to other vaults.
8873

89-
#### ***Create notes and folders***
74+
#### ***Create notes and folders:***
9075

9176
```bash
9277
$ jt note newnote
@@ -98,7 +83,15 @@ $ jt folder newfolder
9883

9984
`note` and `folder`, both work similarly and create the corresponding items in ***current folder***. When a vault is first created, the ***current folder*** is set to its root.
10085

101-
#### ***Change folder***
86+
#### ***Open a note:***
87+
88+
```bash
89+
jt open newnote
90+
```
91+
92+
`open` command will open the specified note with the editor set in config.
93+
94+
#### ***Change folder:***
10295

10396
```bash
10497
$ jt chdir newfolder
@@ -114,7 +107,15 @@ $ jt chdir ..
114107

115108
This will switch back to the root of vault.
116109

117-
#### ***Print dir tree of current folder***
110+
#### ***Open current folder in explorer:***
111+
112+
```bash
113+
$ jt opdir
114+
```
115+
116+
`opdir` command will open the current folder in the default file explorer.
117+
118+
#### ***List items in current folder:***
118119

119120
```bash
120121
$ jt list
@@ -131,9 +132,17 @@ newvault
131132
└── newnote # highlighted in blue
132133
```
133134

134-
#### ***Fs operations***
135+
Adding an item type (***note*** or ***folder***) to the `list` command like so,
135136

136-
Command `remove` works as its name suggests, on all items (vaults, notes, or folders).
137+
```bash
138+
$ jt list note
139+
```
140+
141+
will only list items of the specified type.
142+
143+
#### ***Fs operations:***
144+
145+
Command `remove` works as its name suggests, on all items (***vault***, ***note***, or ***folder***).
137146

138147
```
139148
$ jt remove note newnote
@@ -169,13 +178,21 @@ Every keyword used so far (commands and item names) is interchangeable with its
169178
$ jt mv nt newnote /newfolder/
170179
```
171180

172-
#### ***Handle Jot's config***
181+
#### ***Handle Jot's config:***
182+
183+
```bash
184+
$ jt config
185+
```
186+
187+
`config` command will open the config file in the set ***editor***. By default this is ***nvim***.
188+
189+
Specifying a config field as an argument will display its value without opening the config file itself.
173190

174191
```bash
175192
$ jt config editor
176193
```
177194

178-
The value of the provided field will be printed with `config` command. Providing a value as an additional argument with this command will update the field.
195+
Providing a value as an additional argument will update the field.
179196

180197
```bash
181198
$ jt config editor code.cmd
@@ -199,8 +216,33 @@ $ jt help vault
199216
$ jt vault -h
200217
```
201218

219+
## Notes
220+
221+
#### ***General***
222+
223+
- Jot is published on ***crates.io*** as '***jt***', since 'jot' wasn't available.
224+
- As of now, Jot has only been tested on ***windows*** (and ***WSL***).
225+
226+
#### ***Config & Data***
227+
228+
- App data is stored in config and data files in locations generated by the [***directories***](https://crates.io/crates/directories) crate. Individual Vault data is stored in '***.jot***' folder inside each vault. It is advised that these files not be tampered with, since atm there's no way to automatically fix them.
229+
- App data files are generated in their default state the first time a command is run, if they don't exist already. Vault data files are generated in their default state when a vault is created.
230+
- App config has two fields: ***editor*** & ***conflict***.
231+
- ***editor*** by default is set to ***nvim*** and ***conflict*** to ***true***.
232+
- ***conflict*** field tells jot if the editor conflicts with it for control over the terminal. Set it to *true* for editors like *nvim* and *false* for editors like *notepad*.
233+
202234
## Changelog
203235

236+
- ***v0.1.2*** :
237+
- Fix:
238+
- `list` command could display items other than notes and folders.
239+
- ***process_path()*** couldn't collapse certain paths properly, and ***std::fs::canonicalize*** doesn't work as intended on windows. ***dunce*** crate has been used to achieve the required function.
240+
241+
- Feat:
242+
- `opdir` command has been added to enable opening the current folder in the default file explorer.
243+
- `list` command can now filter items based on the item type provided.
244+
- `config` command can now open the config file in the set editor.
245+
204246
- ***v0.1.1*** :
205247
- As advised by [***u/epage***](https://www.reddit.com/user/epage/) ([github/epage](https://github.com/epage)) on my r/rust [***post***](https://www.reddit.com/r/rust/comments/xebk9j/i_am_working_on_a_cli_alternative_for_obsidian/), commands are now represented by their full word, and the two letter abbreviations (previously serving as commands themselves) are now aliases for these commands.
206248
- Updated docs.
@@ -243,11 +285,12 @@ Pass in commands and arguments after '***--***'.
243285
- [***clap***](https://docs.rs/clap/latest/clap/) has been used to create the command line interface.
244286
- [***directories***](https://docs.rs/directories/latest/directories/) has been used to generate os-dependent config and data file locations.
245287
- [***fs_extra***](https://docs.rs/fs_extra/latest/fs_extra/) has been used for recursive move of folders.
288+
- [***dunce***](https://docs.rs/dunce/latest/dunce/index.html) has been used as an alternative to ***std::fs::canonicalize***.
246289

247290
## Authors
248291

249292
- **araekiel** - [Github](https://github.com/araekiel)
250293

251294
## License
252295

253-
[MIT License](https://github.com/araekiel/jot/blob/main/LICENSE) | Copyright (c) 2022 Kumar Shashwat
296+
[MIT License](https://github.com/araekiel/jot/blob/main/LICENSE) | Copyright (c) 2023 Kumar Shashwat

UPDATES.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/app.rs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,41 @@ impl App {
3434
} => {
3535
if let (Some(name), Some(location)) = (name, location) {
3636
self.vaults.create_vault(name, location)?;
37-
return Ok(Message::ItemCreated(Item::Vl, name.to_owned()));
37+
Ok(Message::ItemCreated(Item::Vl, name.to_owned()))
3838
} else {
3939
self.vaults.list_vaults(show_loc);
40-
return Ok(Message::Empty);
40+
Ok(Message::Empty)
4141
}
4242
}
4343
Command::Enter { name } => {
4444
self.vaults.enter_vault(name)?;
45-
return Ok(Message::VaultEntered(name.to_owned()));
45+
Ok(Message::VaultEntered(name.to_owned()))
4646
}
4747
Command::Note { name } => {
4848
self.vaults
4949
.ref_current()?
5050
.create_vault_item(VaultItem::Nt, name)?;
51-
return Ok(Message::ItemCreated(Item::Nt, name.to_owned()));
51+
Ok(Message::ItemCreated(Item::Nt, name.to_owned()))
5252
}
5353
Command::Open { name } => {
5454
self.vaults
5555
.ref_current()?
5656
.open_note(name, self.config.get_editor_data())?;
57-
return Ok(Message::Empty);
57+
Ok(Message::Empty)
5858
}
5959
Command::Folder { name } => {
6060
self.vaults
6161
.ref_current()?
6262
.create_vault_item(VaultItem::Fd, name)?;
63-
return Ok(Message::ItemCreated(Item::Fd, name.to_owned()));
63+
Ok(Message::ItemCreated(Item::Fd, name.to_owned()))
64+
}
65+
Command::Opdir => {
66+
self.vaults.ref_current()?.open_folder()?;
67+
Ok(Message::Empty)
6468
}
6569
Command::Chdir { path } => {
6670
self.vaults.mut_current()?.change_folder(path)?;
67-
return Ok(Message::FolderChanged);
71+
Ok(Message::FolderChanged)
6872
}
6973
Command::Remove { item_type, name } => {
7074
match item_type {
@@ -74,7 +78,7 @@ impl App {
7478
.ref_current()?
7579
.remove_vault_item(item_type.to_vault_item(), name)?,
7680
};
77-
return Ok(Message::ItemRemoved(item_type.to_owned(), name.to_owned()));
81+
Ok(Message::ItemRemoved(item_type.to_owned(), name.to_owned()))
7882
}
7983
Command::Rename {
8084
item_type,
@@ -89,11 +93,11 @@ impl App {
8993
new_name,
9094
)?,
9195
};
92-
return Ok(Message::ItemRenamed(
96+
Ok(Message::ItemRenamed(
9397
item_type.to_owned(),
9498
name.to_owned(),
9599
new_name.to_owned(),
96-
));
100+
))
97101
}
98102
Command::Move {
99103
item_type,
@@ -108,31 +112,38 @@ impl App {
108112
new_location,
109113
)?,
110114
};
111-
return Ok(Message::ItemMoved(item_type.to_owned(), name.to_owned()));
115+
Ok(Message::ItemMoved(item_type.to_owned(), name.to_owned()))
112116
}
113117
Command::Vmove {
114118
item_type,
115119
name,
116120
vault_name,
117121
} => {
118122
self.vaults.move_to_vault(item_type, name, vault_name)?;
119-
return Ok(Message::ItemVMoved(
123+
Ok(Message::ItemVMoved(
120124
item_type.to_owned(),
121125
name.to_owned(),
122126
vault_name.to_owned(),
123-
));
127+
))
124128
}
125-
Command::List => {
126-
self.vaults.ref_current()?.list();
127-
return Ok(Message::Empty);
129+
Command::List { item_type } => {
130+
self.vaults.ref_current()?.list(item_type);
131+
Ok(Message::Empty)
128132
}
129133
Command::Config { config_type, value } => {
134+
if config_type.is_none() {
135+
self.config.open_config()?;
136+
return Ok(Message::Empty);
137+
}
138+
139+
let config_type = config_type.as_ref().unwrap();
140+
130141
if let Some(value) = value {
131142
self.config.set_config(config_type, value);
132-
return Ok(Message::ConfigSet(config_type.to_owned(), value.to_owned()));
143+
Ok(Message::ConfigSet(config_type.to_owned(), value.to_owned()))
133144
} else {
134145
let value = self.config.get_config(config_type);
135-
return Ok(Message::Config(config_type.to_owned(), value));
146+
Ok(Message::Config(config_type.to_owned(), value))
136147
}
137148
}
138149
_ => Ok(Message::Empty),

0 commit comments

Comments
 (0)