Snipper is a simple, console application
written in PHP for easy import of code snippets from the popular
GitHub Gist service.
Prehistory
One day, I realized that I was rather tired of rewriting small configuration files from a project to a project and began to look for an answer to the question of how to save myself from suffering and not add new ones?
Considering, as it seemed to me, I decided to write a sufficient number of solutions to write my own console “application” to download frequently used files with code (this is about files and not about working with the clipboard). I chose a service from
GitHub for storage, since there is no way to work without it (there are a lot of ready-made libraries for working with API), and for a sipatichnogo appearance, the familiar
Console component from the
Symfony arsenal .
Than did not please the existing solutions?
Found applications are mainly designed to copy the code to the clipboard and have a graphical interface, the need for which I absolutely do not feel. Periodically it was required to upload files with standard settings to a remote server, which is also quite difficult when using “large” utilities. The specificity of my work assumes the presence of
PHP and
Composer on all the machines where I live, so the conclusion suggests itself - to make your own bike.
')
Who is it useful?
Anyone can use Snipper, but due to the fact that it is written in PHP, the main users will be PHP developers. He thought of it as a nice addition to
Composer in order to quickly assemble a start-up project and get started.
I mainly use it to import configurations of text editors and IDEs that support
EditorConfig , for
.env
files, settings for self-written libraries, and even for the standard assembly of client components using
Gulp .
What can Snipper
At the moment, only basic functionality is implemented, namely, getting a file (or files, if there are many of them in gist) by the name of a snippet. However, this is more than enough at the moment to start using
Snipper in combat.
How does it work?
Installation and Setup
You can install
Snipper using
Composer :
composer g require snipper/snipper:@stable
After you need to specify a
personal access token for comfortable work with the
GitHub API :
snipper init <token>
I note that at this time no rights are required to give, although in subsequent versions it may be necessary to allow the creation of gists.
Snippets search
The search is conducted on all gist'am that belong to you and are marked with an asterisk. In the description of the gist, you need to add the name of the snippet by prefixing it with an “all favorite”
hash symbol . You need to search by omitting the hash character, specifying only the name.
If you have a gist with the description "EditorConfig # .editorconfig", then to get a snippet, just run the following command:
snipper get .editorconfig
If several snippets with the same name are found,
Snipper will prompt you to select the desired one from the list.
By default,
Snipper does not overwrite files with the same name, and also reports such cases, but you can explicitly tell the application to overwrite the file (s) if you run the
get
command with the
-f
key.
Finally
Hopefully
Snipper will benefit not only me. I, with pleasure, will consider your suggestions and comments in the description of problems to the repository on
GitHub . Thanks for attention!
References: