kleiner

command module
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

Kleiner - CLI to set up distribution of other clis

Let's face it, go is an excellent tool to build self contained clis, however there is always a question of distribution. You could ask your friends to download new binary from the releases page, however wouldn't it be cooler to have a cli that can report about updates and update itself?

This has been done many times, however kleiner allows to do that at scale since it's so damn easy to generate yet another cli and have it's distribution set up immediately. All you need to do is to add your commands and you're done.

We don't need to have another tool for scaffolding, hence please have cobra-cli installed.

Dependencies:

  • goreleaser to build binaries for us
  • git && github to keep the project and do releases
  • go to build the project
  • GITHUB_TOKEN in the shell environment

Demo

Watch the video

Installation

Install Script

Download kleiner and install into a local bin directory.

MacOS, Linux, WSL

Latest version:

curl -L https://raw.githubusercontent.com/can3p/kleiner/main/generated/install.sh | sh

Specific version:

curl -L https://raw.githubusercontent.com/can3p/kleiner/main/generated/install.sh | sh -s 0.0.4

The script will install the binary into $HOME/bin folder by default, you can override this by setting $CUSTOM_INSTALL environment variable

Manual download

Get the archive that fits your system from the Releases page and extract the binary into a folder that is mentioned in your $PATH variable.

Quick start

  • Install kleiner and it's dependencies
  • Create a new repo on github
  • Clone it to make sure you have origin set up
  • go mod init <username>/<repo>
  • kleiner generate
  • go mod tidy
  • Commit and push
  • Make sure that you have $GITHUB_TOKEN in the environment
  • kleiner release -tag-comment "first release"
  • That's it!

For every next release just work on you changes, push them and run kleiner release again to publish a new version

Inspiration

The code is inspired a lot and uses parts of the flyctl code. The files with the borrowings mention this explicitly.

FAQ

Why is the project named kleiner?

Because it's a cool dutch word! It also bears some similarity with CLI acronym

Why another scaffolding tool?

I think it's useful to be able to be able to start shipping tools in the smallest possible stretch of time. Kleiner will help you to get going with no strings attached - the shared code is small, you can move it to your project and have it under your full control if you want.

Why cobra?

Decisions are hard and to be frank most of the cli handling packages are just fine and any of them would do. You're not tied to cobra in any way, all the included commands are just tiny wrappers that can be replaced by the wrappers that use any other library.

Why github?

I keep my projects on github and github gives a nice API to create releases and upload artifacts. It should be dead easy to add support for gitlab or any other service with comparable feature set.

Why not proper packaging?

Since all the building and packaging is done by goreleaser, you are free to build any packages it supports. The purpose of the structure generated by klein is to specifically bypass traditional packaging solutions in order to deliver instant updates.

If you want to build a cool tool for your company or your friends, you don't want to waste a week trying to build proper packages for the whole zoo of operating systems and architectures available, decide where to host repositories and so on.

Why not setup CI?

The idea is to have the simplest setup possible, local setup fits this scenario

What should I do if I want to get the latest version of release code for my tool?

Just run kleiner generate for your tool again and do a git diff to check for changes. If you haven't modified any files generated by kleiner previously you should be relatively safe to simply commit and push.

I don't like how the artifacts named. Can I change that?

Kleiner relies on convention now and by changing the names you'll break install and update logic. One day this part will be made configurable and then you can have your nice filenames. If you really want to have them now, just copy and modify kleiner code, it's not much.

TODO

  • Windows support
  • Dependencies check (goreleaser, go)
  • Make it possible to generate scaffolding for other git hostings
  • Much better validation and error checking

Projects using kleiner

  • Kleiner itself! Scaffolding was based on initial project code and releases are done with kleiner

License

Apache 2.0

Documentation

Overview

Copyright © 2024 Dmitrii Petrov <[email protected]>

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.

Directories

Path Synopsis
generated
internal
shared

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL