Skip to content

Commit

Permalink
Merge pull request #11 from araekiel/v0.1.2
Browse files Browse the repository at this point in the history
V0.1.2
  • Loading branch information
shashwatah committed Apr 5, 2023
2 parents a9f9302 + 6b2e153 commit 07e215b
Show file tree
Hide file tree
Showing 16 changed files with 306 additions and 194 deletions.
9 changes: 8 additions & 1 deletion Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jt"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["araekiel <kumarshashwatsri@gmail.com>"]
license = "MIT"
Expand All @@ -17,3 +17,4 @@ toml = "0.5.9"
clap = { version = "3.2.15", features = ["derive"] }
directories = "4.0.1"
fs_extra = "1.2.0"
dunce = "1.0.3"
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Kumar Shashwat
Copyright (c) 2023 Kumar Shashwat

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
99 changes: 71 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# *jot*

[![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)
<a href="LICENSE"><img alt="Release" src="https://img.shields.io/badge/license-MIT-green"></a>
<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>
<a href="https://crates.io/crates/jt"><img alt="Cargo" src="https://img.shields.io/badge/cargo-jt-blue"></a>
<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>
<a href="https://crates.io/crates/jt"><img alt="Cargo" src="https://img.shields.io/badge/crates.io-jt-blue"></a>

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

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

<br>

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>
Check out [***UPDATES.md***](UPDATES.md) to see upcoming updates. ***This project is not open to contributions at the moment.***

## Installation

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

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

Download [***jt.exe***](https://github.com/araekiel/jot/releases/download/v0.1.1/jt.exe) (***v0.1.1***) and add it to your path.

## Notes

- 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.
- 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.
- App config has two fields: ***editor*** & ***conflict***.
- ***editor*** by default is set to ***nvim*** and ***conflict*** to ***true***.
- ***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*.
- Jot is published on ***crates.io*** as '***jt***', since 'jot' wasn't available.
Download [***jt.exe***](https://github.com/araekiel/jot/releases/download/v0.1.2/jt.exe) (***v0.1.2***) and add it to your path.

## Usage

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

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).
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).

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

Expand All @@ -86,7 +71,7 @@ $ jt enter newvault

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

#### ***Create notes and folders***
#### ***Create notes and folders:***

```bash
$ jt note newnote
Expand All @@ -98,7 +83,15 @@ $ jt folder newfolder

`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.

#### ***Change folder***
#### ***Open a note:***

```bash
jt open newnote
```

`open` command will open the specified note with the editor set in config.

#### ***Change folder:***

```bash
$ jt chdir newfolder
Expand All @@ -114,7 +107,15 @@ $ jt chdir ..

This will switch back to the root of vault.

#### ***Print dir tree of current folder***
#### ***Open current folder in explorer:***

```bash
$ jt opdir
```

`opdir` command will open the current folder in the default file explorer.

#### ***List items in current folder:***

```bash
$ jt list
Expand All @@ -131,9 +132,17 @@ newvault
└── newnote # highlighted in blue
```

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

Command `remove` works as its name suggests, on all items (vaults, notes, or folders).
```bash
$ jt list note
```

will only list items of the specified type.

#### ***Fs operations:***

Command `remove` works as its name suggests, on all items (***vault***, ***note***, or ***folder***).

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

#### ***Handle Jot's config***
#### ***Handle Jot's config:***

```bash
$ jt config
```

`config` command will open the config file in the set ***editor***. By default this is ***nvim***.

Specifying a config field as an argument will display its value without opening the config file itself.

```bash
$ jt config editor
```

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.
Providing a value as an additional argument will update the field.

```bash
$ jt config editor code.cmd
Expand All @@ -199,8 +216,33 @@ $ jt help vault
$ jt vault -h
```

## Notes

#### ***General***

- Jot is published on ***crates.io*** as '***jt***', since 'jot' wasn't available.
- As of now, Jot has only been tested on ***windows*** (and ***WSL***).

#### ***Config & Data***

- 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.
- 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.
- App config has two fields: ***editor*** & ***conflict***.
- ***editor*** by default is set to ***nvim*** and ***conflict*** to ***true***.
- ***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*.

## Changelog

- ***v0.1.2*** :
- Fix:
- `list` command could display items other than notes and folders.
- ***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.

- Feat:
- `opdir` command has been added to enable opening the current folder in the default file explorer.
- `list` command can now filter items based on the item type provided.
- `config` command can now open the config file in the set editor.

- ***v0.1.1*** :
- 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.
- Updated docs.
Expand Down Expand Up @@ -243,11 +285,12 @@ Pass in commands and arguments after '***--***'.
- [***clap***](https://docs.rs/clap/latest/clap/) has been used to create the command line interface.
- [***directories***](https://docs.rs/directories/latest/directories/) has been used to generate os-dependent config and data file locations.
- [***fs_extra***](https://docs.rs/fs_extra/latest/fs_extra/) has been used for recursive move of folders.
- [***dunce***](https://docs.rs/dunce/latest/dunce/index.html) has been used as an alternative to ***std::fs::canonicalize***.

## Authors

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

## License

[MIT License](https://github.com/araekiel/jot/blob/main/LICENSE) | Copyright (c) 2022 Kumar Shashwat
[MIT License](https://github.com/araekiel/jot/blob/main/LICENSE) | Copyright (c) 2023 Kumar Shashwat
36 changes: 0 additions & 36 deletions UPDATES.md

This file was deleted.

47 changes: 29 additions & 18 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,41 @@ impl App {
} => {
if let (Some(name), Some(location)) = (name, location) {
self.vaults.create_vault(name, location)?;
return Ok(Message::ItemCreated(Item::Vl, name.to_owned()));
Ok(Message::ItemCreated(Item::Vl, name.to_owned()))
} else {
self.vaults.list_vaults(show_loc);
return Ok(Message::Empty);
Ok(Message::Empty)
}
}
Command::Enter { name } => {
self.vaults.enter_vault(name)?;
return Ok(Message::VaultEntered(name.to_owned()));
Ok(Message::VaultEntered(name.to_owned()))
}
Command::Note { name } => {
self.vaults
.ref_current()?
.create_vault_item(VaultItem::Nt, name)?;
return Ok(Message::ItemCreated(Item::Nt, name.to_owned()));
Ok(Message::ItemCreated(Item::Nt, name.to_owned()))
}
Command::Open { name } => {
self.vaults
.ref_current()?
.open_note(name, self.config.get_editor_data())?;
return Ok(Message::Empty);
Ok(Message::Empty)
}
Command::Folder { name } => {
self.vaults
.ref_current()?
.create_vault_item(VaultItem::Fd, name)?;
return Ok(Message::ItemCreated(Item::Fd, name.to_owned()));
Ok(Message::ItemCreated(Item::Fd, name.to_owned()))
}
Command::Opdir => {
self.vaults.ref_current()?.open_folder()?;
Ok(Message::Empty)
}
Command::Chdir { path } => {
self.vaults.mut_current()?.change_folder(path)?;
return Ok(Message::FolderChanged);
Ok(Message::FolderChanged)
}
Command::Remove { item_type, name } => {
match item_type {
Expand All @@ -74,7 +78,7 @@ impl App {
.ref_current()?
.remove_vault_item(item_type.to_vault_item(), name)?,
};
return Ok(Message::ItemRemoved(item_type.to_owned(), name.to_owned()));
Ok(Message::ItemRemoved(item_type.to_owned(), name.to_owned()))
}
Command::Rename {
item_type,
Expand All @@ -89,11 +93,11 @@ impl App {
new_name,
)?,
};
return Ok(Message::ItemRenamed(
Ok(Message::ItemRenamed(
item_type.to_owned(),
name.to_owned(),
new_name.to_owned(),
));
))
}
Command::Move {
item_type,
Expand All @@ -108,31 +112,38 @@ impl App {
new_location,
)?,
};
return Ok(Message::ItemMoved(item_type.to_owned(), name.to_owned()));
Ok(Message::ItemMoved(item_type.to_owned(), name.to_owned()))
}
Command::Vmove {
item_type,
name,
vault_name,
} => {
self.vaults.move_to_vault(item_type, name, vault_name)?;
return Ok(Message::ItemVMoved(
Ok(Message::ItemVMoved(
item_type.to_owned(),
name.to_owned(),
vault_name.to_owned(),
));
))
}
Command::List => {
self.vaults.ref_current()?.list();
return Ok(Message::Empty);
Command::List { item_type } => {
self.vaults.ref_current()?.list(item_type);
Ok(Message::Empty)
}
Command::Config { config_type, value } => {
if config_type.is_none() {
self.config.open_config()?;
return Ok(Message::Empty);
}

let config_type = config_type.as_ref().unwrap();

if let Some(value) = value {
self.config.set_config(config_type, value);
return Ok(Message::ConfigSet(config_type.to_owned(), value.to_owned()));
Ok(Message::ConfigSet(config_type.to_owned(), value.to_owned()))
} else {
let value = self.config.get_config(config_type);
return Ok(Message::Config(config_type.to_owned(), value));
Ok(Message::Config(config_type.to_owned(), value))
}
}
_ => Ok(Message::Empty),
Expand Down
Loading

0 comments on commit 07e215b

Please sign in to comment.