Skip to content
/ kleiner Public

a self-updatable cli to generate projects with self-updatable clis

License

Notifications You must be signed in to change notification settings

can3p/kleiner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

a self-updatable cli to generate projects with self-updatable clis

Resources

License

Stars

Watchers

Forks

Packages

No packages published