Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch 1: Github Actions, Brew recipe, linting suggestions, fish completion etc #4

Merged
merged 26 commits into from
Apr 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5cd1df1
Implement linting suggestions from cargo clippy
zph Mar 8, 2021
710c3c0
Add github actions workflow
zph Mar 8, 2021
d6e110c
Fix incorrect toolchain name
zph Mar 8, 2021
f8a412f
Ignore failing test until determined valid
zph Mar 8, 2021
1669622
Use collect to simplify remaining_args
zph Mar 8, 2021
b5cb69a
Complete renaming from cookbook to tome
zph Mar 8, 2021
834dc2d
Disable cargo config because it breaks compilation when run from mac
zph Mar 12, 2021
8ca9929
Add fish completion to tome and fix completion panic
zph Mar 12, 2021
0992ad5
Update docs to mention fish shell
zph Mar 12, 2021
93f5eb7
Update docs to mention fish shell
zph Mar 12, 2021
43b18f4
Add homebrew formula
zph Mar 12, 2021
228610c
Tidy up homebrew formula
zph Mar 12, 2021
10f23c0
Update brew recipe for correct endpoint
zph Mar 18, 2021
b20f4b0
Try using symlink as main readme
zph Mar 16, 2021
211378a
Propose adding a Rust standard license of MIT
zph Mar 18, 2021
63ccd00
Switch away from .cargo/config for cross compilation settings
zph Mar 18, 2021
529b699
Update docs to reference cross compilation tooling
zph Mar 18, 2021
71137c1
Remove test related to passing --complete arg to a sourcing file
zph Mar 18, 2021
a936a36
Autoformat
zph Mar 19, 2021
e8e9766
Revert "Remove test related to passing --complete arg to a sourcing f…
zph Mar 20, 2021
7ecbdd2
Un-ignore test_source_completion
zph Mar 20, 2021
0ab5ab2
Force SHELL=bash for test that depends on sourced script being bash
zph Mar 21, 2021
e440cd2
Move development documentation to CONTRIBUTING.md
zph Mar 21, 2021
21edce0
Remove homebrew tests
zph Apr 2, 2021
588bbd6
Reduce duplication in init.rs among shells
zph Apr 2, 2021
16872b0
Revert "Reduce duplication in init.rs among shells"
zph Apr 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .cargo/config

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on: [push]
zph marked this conversation as resolved.
Show resolved Hide resolved
name: build
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
- name: build
uses: actions-rs/cargo@v1
with:
command: build
- name: test
uses: actions-rs/cargo@v1
with:
command: test
- name: lint
uses: actions-rs/clippy-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
12 changes: 6 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'cookbook'",
zph marked this conversation as resolved.
Show resolved Hide resolved
"name": "Debug executable 'tome'",
"cargo": {
"args": [
"build",
"--bin=cookbook",
"--package=cookbook"
"--bin=tome",
"--package=tome"
],
"filter": {
"kind": "bin"
Expand All @@ -24,13 +24,13 @@
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'cookbook'",
"name": "Debug unit tests in executable 'tome'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=cookbook",
"--package=cookbook"
"--bin=tome",
"--package=tome"
],
"filter": {
"kind": "bin"
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "tome"
version = "0.1.0"
authors = ["Yusuke Tsutsumi <yusuke@tsutsumi.io>"]
edition = "2018"
license = "MIT"

[dependencies]
tui = "0.3.0"
Expand Down
1 change: 1 addition & 0 deletions HomebrewFormula
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Yusuke Tsutsumi
zph marked this conversation as resolved.
Show resolved Hide resolved

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 0 additions & 26 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
12 changes: 12 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash

set -eou pipefail
set -x

readonly TARGETS=(x86_64-unknown-linux-musl x86_64-apple-darwin)

source <(./bin/setenv)

for target in "${TARGETS[@]}";do
cargo build --release --target "$target"
done
25 changes: 25 additions & 0 deletions bin/setenv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# USAGE: ./bin/setenv
# SUMMARY: Set env outputs the correct environmental variables to cross compile to
# linux and darwin from either a build platform of linux or darwin.
# Run this script before trying to do cross compilation.
# Credit: http://timryan.org/2018/07/27/cross-compiling-linux-binaries-from-macos.html

set -eou pipefail

# Build platform
OS="$(uname -a | awk '{print tolower($1)}')"

case "$OS" in
"darwin")
echo export CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER="x86_64-linux-musl-gcc"
;;
"linux")
echo export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER="x86_64-apple-darwin15-clang"
echo export CARGO_TARGET_X86_64_APPLE_DARWIN_AR="x86_64-apple-darwin15-ar"
;;
*)
echo -e "Unknown build platform, only darwin and linux are supported"
exit 1
;;
esac
27 changes: 27 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing

### Testing

`cargo test`

### Linting

`cargo clippy`

### Compiling for build platform (ie linux on linux)

```
# debug
cargo build
# release
cargo build --release
```

### Cross compile (linux on darwin) release builds

This is a portable script that sets up ENV variables to allow for cross compiling
from darwin to linux or reverse.

```
./bin/release
```
39 changes: 31 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
# Introduction

## Quickstart
- Download binary for platform from Releases
- Add init command to your shell init: ie for zsh add to ~/.zshrc
```
eval "$(tome init my-commands ~/my-scripts zsh)"
```
- `my-commands --help`

## What is Tome?

Tome provides easy organization
and execution of collections of command line scripts.
Tome provides easy organization and execution of collections of command line scripts.

Basically take a directory of scripts like this:
With a directory of scripts like this:

```
root/
Expand All @@ -20,7 +27,7 @@ root/
provision-my-service
```

And be able run them like:
Tome allows for executing them like:

```
$ my-command go-to-workspace
Expand All @@ -35,7 +42,7 @@ And add in some features for discoverability:

* tab-completion
* search all available commands (just enter your command with no arguments)
* TODO: help commands
* help commands

## Why?

Expand All @@ -47,6 +54,9 @@ This works well for a small group, but once you're trying to share scripts acros
* namespacing: how do I find commands that relate to what I'm working on?
* completion: It's nice

### Prior Art & Inspiration
https://github.com/basecamp/sub

## Getting Started

### 1. Download Tome
Expand All @@ -72,7 +82,7 @@ root/

(keeping these in version control is recommended)

Put them in a well known, persistent location as well (e.g. ~/my-scripts).
Put them in a well known, persistent location as well (e.g. ~/my-scripts).

### 3. Put The Initialization Code in your .rc file

Expand All @@ -81,12 +91,25 @@ to be named "my-commands" you'd put the following in your .bashrc or .zshrc:

```
# posix example, e.g. .bashrc
eval "`~/bin/tome init my-commands ~/my-scripts $0`"
eval "$(tome init my-commands ~/my-scripts bash)"

# zsh
zph marked this conversation as resolved.
Show resolved Hide resolved
eval "$(tome init my-commands ~/my-scripts zsh)"
```

For fish shell:
```
# in ~/.config/fish/conf.d/tome.fish
tome init my-commands ~/my_script_dir $0 | source
```

*NOTE*: make sure to include the double quotes with the nested backticks. This ensures that newlines are captured
and evaluated appropriately.

### 4. Start a New Shell

Once installed, start a new shell and you should have your new command!
Once installed, start a new shell and you should have your new command!

## Developing Tome
zph marked this conversation as resolved.
Show resolved Hide resolved

See CONTRIBUTING.md
18 changes: 18 additions & 0 deletions pkg/brew/tome.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class Tome < Formula
HOMEPAGE = "https://github.com/toumorokoshi/tome"

desc "Modern replacement for 'sub'"
homepage HOMEPAGE
url HOMEPAGE
license "MIT"
version '0.1.0'
zph marked this conversation as resolved.
Show resolved Hide resolved
revision 1

head "#{HOMEPAGE}.git"

depends_on "rust" => :build
zph marked this conversation as resolved.
Show resolved Hide resolved

def install
system "cargo", "install", *std_cargo_args
end
end
4 changes: 2 additions & 2 deletions src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ pub fn help(root: &str, mut _args: Peekable<Iter<String>>) -> io::Result<String>
escape_slashes(&script.summary_string)
))
}
return Ok(format!(
zph marked this conversation as resolved.
Show resolved Hide resolved
Ok(format!(
help_template!(),
root,
commands_with_help.join("\\n")
));
))
}

// escape slash characters with posix-compatible quotes. Helps if the echo
Expand Down
Loading