Skip to content

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Stanley committed Jan 10, 2020
2 parents b1ce274 + 8fffe56 commit de2f095
Show file tree
Hide file tree
Showing 76 changed files with 1,745 additions and 41,296 deletions.
1 change: 0 additions & 1 deletion .crystal-version

This file was deleted.

2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
crystal 0.30.1
crystal 0.31.1
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
language: crystal

# Uncomment the following if you'd like Travis to run specs and check code formatting
# script:
# - crystal spec
# - crystal tool format --check
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## 0.3.0

### Features

* Upgraded Crystal to 0.31.1
* Overhauled the search command
* New NCurses TUI
* Fuzzy match searching.
* Deleting snippets via search.
* Editing snippets via search.
* Copy/run snippets via search
* Ability to edit and delete commands through the search interface.
* Moved from JSON storage to Sqlite - including a built in migration process
* Syncing snippets improvements:
* New local-only snippets will sync back to Snipline Cloud.
* Snipline Cloud snippets will now delete locally on sync.
* Locally edited snippets will sync back to Snipline Cloud.
* New `--dry-run` flag to see what will change during sync.
* New `--verbose` flag to see what has changed during sync.

### Changes

* Refactoring and testing to various classes.
* Snippets are now stored in an Sqlite database rather than JSON file.
* `sync` command now migrates the Sqlite database.
* Added Crecto for managing snippets from Sqlite.

### Bugfixes

None

## 0.2.0

### Features
Expand All @@ -13,6 +44,7 @@
* `search` command now copies the selected snippet instead of running.
* Updated Crystal to `0.30.1`
* Updated `lodash` dependency for `web` interface.
* Removed `web` command.

### Bugfixes

Expand Down
26 changes: 0 additions & 26 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Mitchell Stanley
Copyright (c) 2019 Mitchell Stanley

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
97 changes: 34 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Snipline CLI

Snipline CLI is the command-line tool for [Snipline](https://snipline.io).
Snipline CLI allows you to organise and use your favourite shell commands from the terminal. It can optionally sync to your [Snipline](https://snipline.io) account.

![SnipCLI Preview](https://f002.backblazeb2.com/file/ms-uploads/snipline/2019-07-10%2010.41.26.gif)

Snipline CLI allows you to search and run commands from your Snipline account directly through the command-line. It is also possible to use this for free without a Snipline account (See the documentation on using without a Snipline Account).
<p align="center">
<img src="https://f002.backblazeb2.com/file/snipline/2019-10-14+12.02.35.gif" alt="SnipCLI Preview"/>
</p>

## Installation

Expand All @@ -26,7 +26,7 @@ sudo snap install snipcli --beta

### From source

Snipline CLI requires Crystal 0.29.0 to be installed to install from source
Snipline CLI requires Crystal 0.30.1 to be installed to install from source

```bash
# Install dependencies
Expand All @@ -37,6 +37,18 @@ crystal build src/snipline_cli.cr -o snipcli --release

## Usage

### Using Snipline CLI for free

Snipline CLI can be used without an active Snipline account.

To generate the initial configuration files use the `init` command.

```bash
snipcli init
```

The above command will generate a `config.toml` file and a `snippets.json` file in your `~/.config/snipline` directory.

### Syncing to Snipline

Log-in to your Snipline account and sync your snippets.
Expand All @@ -47,85 +59,43 @@ Follow login instructions (Enter email and token)
snipcli login
```

Download snippets from your account
### Download snippets from your Snipline account

**Note:: At the time of writing this will clear any unsynced snippets on your machine. This will be changed with a future update**

```bash
snipcli sync
```

This will create two files on your system: `~/.config/snipline/config.toml` and `~/.config/snipline/snippets.json`.

### Searching snippets

A basic search can be done with the `search` command.

```bash
snipcli search <searchterm>
snipcli search
```

By default search will ask if you wish to copy the result to clipboard, to run the result in the current terminal, use the `run` flag.
If you wish to pre-filter the results you can do so by adding a search term and specify the field to search on.

```bash
snipline search <searchterm> --run
snipcli search <searchterm> --field=tags
```

Search options include `field`, `limit`, `run`. See `snipcli search --help` for more information
Search options include `field` and `limit`. See `snipcli search --help` for more information

Note that as of 0.2.0 it's not possible to search and copy to clipboard from a Linux VM/SSH session. Select `no` when prompted to copy to clipboard to continue and use the `--run` flag to run the command instead.
Note that as of 0.2.0 it's not possible to search and copy to clipboard from a Linux VM/SSH session. Use `run` to run the command directly from your terminal session.

### Creating a new snippet

You can create a new snippet by using the `new` command. This will open a TOML file in the text editor of your preference. Once closed it will attempt to add it to your `snippets.json` file and sync to Snipline Cloud.
You can create a new snippet by using the `new` command. This will open a TOML file in the text editor of your preference. Once closed it will attempt to add it to your `snippets.json` file and sync to your Snipline Account.

```bash
snipline new
snipcli new
```

### Web interface

Snipline CLI comes with a lightweight web interface. To use it run

```
snipcli web
```

You can then view and edit snippets through a web browser. By default this works locally on port 9876, however, you can specify it to be accessible remotely with the following arguments.

```bash
snipcli web -p 3000 -b 0.0.0.0
```

### Using Snipline CLI without a Snipline Account

Snipline CLI can be used without an active Snipline account. But requires either manually entering data in the `~/.config/snipline/snippets.json` file or using the `web` interface.

To generate the initial configuration files use the `init` command.

```bash
snipcli init
```

At this moment the web interface does not support CRUD commands and manual entry is required.

Here is an example ~/.config/snipline/snipets.json` file to get started.

Note that `id` of `null` means that it has not been synced to a Snipline account. It will be lost if `snipcli sync` is ever run to fetch snippets from Snipline.

```json
[
{
"id":null,
"type":"snippets",
"attributes":
{
"is-pinned":false,
"name":"Symlink directory",
"real-command":"ln -s #{[Source]} #{[Destination]}",
"tags":["file", "linux"]
}
}
]
```
As of 0.3.0 the web interface has been removed infavour of the new TUI.

## Development

Expand All @@ -140,8 +110,10 @@ env LOG_LEVEL=DEBUG ./snipcli search git

To change the config file location (For testing) use the `CONFIG_FILE` environment variable.

There is an example already in place for testing located in `config.spec.toml`

```bash
env CONFIG_FILE=./spec/fixtures/config.toml ./snipcli search git
env CONFIG_FILE=./config.spec.toml crystal spec
```

## Contributing
Expand All @@ -151,11 +123,10 @@ See the [Contributing guide](CONTRIBUTING.md) for details.
## TODO

* More tests.
* Create snippets through web interface.
* Edit snippets through web interface.
* Delete snippets through web interface.
* More documentation (Including usage without a Snipline account).
* Table formatting for search results.
* Syncing local snippets via `snipcli sync`.
* Editing snippets.
* Compact search mode.

## Contributors

Expand Down
7 changes: 0 additions & 7 deletions assets/css/app.css

This file was deleted.

103 changes: 0 additions & 103 deletions assets/css/components/snipline-list-item.css

This file was deleted.

Empty file removed assets/js/app.js
Empty file.
10 changes: 10 additions & 0 deletions config.spec.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title = "Snipline"

[api]
url = "http://localhost:4001/api"
token = ""

[general]
db = "./test.db"
file = "./snippets.json"
temp_dir = "./temp"
4 changes: 0 additions & 4 deletions mix-manifest.json

This file was deleted.

Loading

0 comments on commit de2f095

Please sign in to comment.