DEV Community

Cover image for Buck - Get started with your projects faster.
Pleasant Tech
Pleasant Tech

Posted on

Buck - Get started with your projects faster.

The command line interface ( CLI ) or terminal is a computer program used by hundreds of millions of people around the world both on Mobile and on a PC to run local commands like, make a new directory, list all the files in a directory or run global commands like deploy a new version of your app or push to GitHub .
It's a lightweight and not so great looking interface to communicate with your computer , it's also free and fast , it's so great that programmers even write code in it using tools like vim , let's pause for a moment to appreciate our command line for serving us till this day.

Developers who work with the CLI can install external packages and CLI tools and on Linux os you can even install programs directly, the CLI is also used to startup projects , like making project directories, making files in them, opening them in vs code, initialising their projects as node project's and so many more , however in most cases starting up a project can take a lot of time, running commands individually (in some cases ) and repeatedly, the other day I wanted to start a new python project and I needed to make a new virtual environment, but I just didn't remember the right packages name to install even though I've used them in a previous project before, if you have ever faced this you'd probably have had to Google the packages names and probably versions or just look into your previous project in some part of your code to figure out what the package names are .
This can really slow you down sometimes , in my case I had no internet connection and I couldn't find my previous project, so I had to wait hours before I could Google it up and this is a terrible practice. But good news, there's a way to solve it , Buck !

For you all bucket lovers this is for you !

Buck is a short form of Bucket , why didn't I just choose Bucket ?
Well I don't like the word and it just isn't my type of word, that's just a joke lol, someone already picked the name.😔

Moving on, Buck is a cli tool that allows you store multiple commands in a bucket , and the content in the bucket can be executed with a custom keyword of your choice in the terminal.

Buck automates processes and re occuring commands when getting started on a new project which allows you focus more on writing code and building stuffs other than setting up.

Alright so let's get started, in this demo I'd be showing you how to Install and use buck.

-Installation

For now buck is only available on pip so ensure you have python and pip installed, if you have that already, go on to your terminal and install buck,

Pip install buck , buck is very lightweight and it doesn't come with external packages so it should be installed and ready to go quickly.

-Demo

I'd be showing you how to use buck to automate 13 cli commands all with one custom keyword of your choice.
This bucket will go into your project directory, create a new folder with a custom name of your choice from the cli, go into the folder, create a js folder and an index.js file in it, create a css folder and a style.css file in it, cd back into the main directory and create an index.html file and intialise it as a git repository with the git init command.

Normally in the cli you may run these following commands for that :

  1. cd
  2. mkdir
  3. cd 4.mkdir js
  4. cd js
  5. touch index.js
  6. cd ..
  7. mkdir css
  8. cd css
  9. touch style.css
  10. cd ..
  11. touch index.html
  12. git init

Which could take you a minute or less, and you might have to do this for every new project, so why don't we group all the re occuring commands together and execute them all at once.

-Creating a new bucket

You can create a new bucket with the buck -c or buck --create command, it will ask you for informations about the new bucket,
I. Name (The name of the bucket ) , in this case we would call it frontend.

  1. Commands This is the list of commands that you want to be run anytime you call the keyword , please take note that the commands would be run synchronously. ❗ Please separate your commands only with a ','

In this case we just paste in the commands we would run normally but with a few tweaks 👇

  1. cd
  2. mkdir $
  3. cd $ 4.mkdir js
  4. cd js
  5. touch index.js
  6. cd ..
  7. mkdir css
  8. cd css
  9. touch style.css
  10. cd ..
  11. touch index.html
  12. git init

In this case we replace the project name with a dollar sign '$' i.e when we run the command we want to pass in an extra argument which would replace the dollar command, I would explain better when we are running this bucket.

  1. Executor (This is the keyword , the magic word, the master word you use to execute all the commands in the bucket) in this case I would call it frontend (you could call it anything)

  2. Description (A description about the bucket and what it does, you can skip this by clicking enter) in this case we say 'It creates a new web project'.
    After you are done setting all of that up, click enter and you'd get success message, hurray ! you've just created your first bucket .😀

-Viewing your buckets

You can view all the buckets you have created with the buck -l or buck --list command, this would list all the buckets you have in a json format, if we run this now we would only get one json object with the informations about the bucket we just created.

-Running the bucket commands

This doesn't have a special keyword , just the buck + the executor of the bucket you want to run.

In this case we would run 'buck frontend' it would output an error message saying it takes in an extra argument, that is because we added a '$' sign to our bucket list which means we are expecting one more argument to replace the dollar sign, if we run buck frontend Uber, it would replace every part of the command lists that has the '$' sign with the extra argument we passed in , in this case when we run buck frontend Uber, it would replace the dollar sign with Uber , thus we have :

  1. cd
  2. mkdir Uber
  3. cd Uber 4.mkdir js
  4. cd js
  5. touch index.js
  6. cd ..
  7. mkdir css
  8. cd css
  9. touch style.css
  10. cd ..
  11. touch index.html
  12. git init

So just in case you have an idea for a new startup called Facebook 😉, you can run the 'buck Frontend Facebook' command , and it will run all of the 13 commands for you very fast.

There are much more better examples and use cases, we could create a bucket that installs the major packages we need in a new project just in case we are working with a new environment, a bucket to automate pushing a new version of your app to the cloud and so much more with buck.

Go ahead, try it out now :

https://pypi.org/project/buck/

Buck is also an open source tool, so I'd be more than happy to see you contribute to this

https://github.com/Pleasant-tech/Buck

Thank you bucket nation. ❤️

Top comments (0)