2019-03-22 19:29:13 +00:00
|
|
|
# ttm.sh CLI
|
2019-03-22 10:47:56 +00:00
|
|
|
|
2019-03-22 19:29:13 +00:00
|
|
|
A CLI application for interacting with ttm.sh.
|
|
|
|
|
2019-03-23 22:49:59 +00:00
|
|
|
[![asciicast](https://asciinema.org/a/235982.svg)](https://asciinema.org/a/235982)
|
|
|
|
|
2019-03-22 19:46:33 +00:00
|
|
|
*Although this is mainly a CLI application, there is also a [module](#3-module) that you can use in your own projects!*
|
|
|
|
|
|
|
|
<!-- TOC -->
|
|
|
|
|
|
|
|
- [1. Installation](#1-installation)
|
|
|
|
- [1.1. From NPM](#11-from-npm)
|
|
|
|
- [1.2. From Source](#12-from-source)
|
|
|
|
- [2. Usage](#2-usage)
|
|
|
|
- [2.1. Shorten](#21-shorten)
|
|
|
|
- [2.2. Upload](#22-upload)
|
|
|
|
- [3. Module](#3-module)
|
|
|
|
- [4. Contributing](#4-contributing)
|
|
|
|
|
|
|
|
<!-- /TOC -->
|
|
|
|
|
|
|
|
## 1. Installation
|
|
|
|
|
|
|
|
### 1.1. From NPM
|
|
|
|
|
|
|
|
This method is recommended as there is less setup.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
npm install -g ttmsh
|
|
|
|
# now you can use the command 'ttmsh'
|
|
|
|
```
|
|
|
|
|
|
|
|
### 1.2. From Source
|
2019-03-22 19:29:13 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
git clone https://tildegit.org/jakew/ttmsh-cli.git
|
|
|
|
cd ttmsh-cli
|
|
|
|
npm install
|
|
|
|
npm link
|
|
|
|
# now you can use the command 'ttmsh' or 'node ./cli.js' or './cli.js' (only on nix)
|
|
|
|
```
|
|
|
|
|
2019-03-22 19:46:33 +00:00
|
|
|
## 2. Usage
|
2019-03-22 19:29:13 +00:00
|
|
|
|
2019-03-22 19:46:33 +00:00
|
|
|
### 2.1. Shorten
|
2019-03-22 19:29:13 +00:00
|
|
|
|
|
|
|
You can either include the URL in your command:
|
|
|
|
|
|
|
|
```console
|
|
|
|
jakew@tilde:~$ ttmsh shorten https://google.co.uk
|
|
|
|
√ https://ttm.sh/Ef
|
|
|
|
```
|
|
|
|
|
|
|
|
...or not include it and be asked later:
|
|
|
|
|
|
|
|
```console
|
|
|
|
jakew@tilde:~$ ttmsh shorten
|
|
|
|
√ Which URL would you like to shorten? · https://google.co.uk
|
|
|
|
√ https://ttm.sh/Ef
|
|
|
|
```
|
|
|
|
|
|
|
|
*Note: You will be asked again if you pass in an invalid URL.*
|
|
|
|
|
2019-03-22 19:46:33 +00:00
|
|
|
### 2.2. Upload
|
2019-03-22 19:29:13 +00:00
|
|
|
|
|
|
|
Like with [shorten](#shorten), you can either include a file path in your command:
|
|
|
|
|
|
|
|
```console
|
|
|
|
jakew@tilde:~$ ttmsh upload message.txt
|
|
|
|
√ https://ttm.sh/j0.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
...or don't include it and be asked later:
|
|
|
|
|
|
|
|
```console
|
|
|
|
jakew@tilde:~$ ttmsh upload
|
|
|
|
√ Which file would you like to upload? · message.txt
|
|
|
|
√ https://ttm.sh/j0.txt
|
|
|
|
```
|
|
|
|
|
2019-03-22 19:46:33 +00:00
|
|
|
## 3. Module
|
|
|
|
|
|
|
|
You can also use the mini API wrapper in your application. Here's some example code on how to use it.
|
|
|
|
|
|
|
|
```js
|
|
|
|
const ttmsh = require("ttmsh");
|
|
|
|
|
|
|
|
// upload a file to ttm.sh
|
|
|
|
ttmsh.do("upload", "/path/to/file/to/upload.txt").then((result) => {
|
|
|
|
console.log(`Here's your link: ${result}`);
|
|
|
|
}).catch((err) => {
|
|
|
|
console.error("Something went wrong.", err);
|
|
|
|
});
|
|
|
|
|
|
|
|
// shorten a link with ttm.sh
|
|
|
|
ttmsh.do("shorten", "https://example.com/this/is/a/long/url").then((result) => {
|
|
|
|
console.log(`Here's your link: ${result}`);
|
|
|
|
}).catch((err) => {
|
|
|
|
console.error("Something went wrong.", err);
|
|
|
|
});
|
|
|
|
```
|
|
|
|
|
|
|
|
## 4. Contributing
|
2019-03-22 19:29:13 +00:00
|
|
|
|
|
|
|
I'd love for people to add in new features and improve on my current work so feel free to open a pull request!
|