angelmmiguel / fu Goto Github PK
View Code? Open in Web Editor NEWA modern du replacement, with new features and a better output
License: Apache License 2.0
A modern du replacement, with new features and a better output
License: Apache License 2.0
Currently, the CLI iterates over the list of elements and prints the results directly. To add features like sorting or top, I would need to first calculate and store all the information in a list and then, perform any sorting and filtering.
For now, I´m going to split the logic and store the information. Then, I will print it using the current approach.
Now that I'm preparing the first release, I want the binaries to be generated and uploaded automatically using GitHub actions. For the first initial release, I will draft it manually but it would be nice to automate this process
The --graph
or -g
option will enable a graph on the right of the different files. It provides a visual hint about the percentage of the file size in the total amount.
To represent this information in the terminal, I will use the full block character: █
. This allow me to show a full block to represent the different percentages:
$ fu --top 2 ./
DISK BYTES PATH
258M 238M target ████████████████████
492K 71K .git █
The total will be represented by 20 blocks, so we can properly calculate the number of blocks to show. These blocks will use the proper color too.
In addition to that, this can be enabled by default using the FU_GRAPH_MODE
environment variable.
I want to add a bit more information about the file size than current du
approach. I will explore the different approaches for the ouptut of every entry in the response.
In addition to that, I can also add a summary line with the totals. This line won't be displayed based on an optional parameter.
the end goal of this CLI is to provide a good replacement for du
. Said that, it should allow the same arguments as du
would receive, as well as other new and simpler ways.
du
allows to calculate the size of multiple files by using a glob pattern (ex. du ./*
). This behavior will be reproduced by fu
. In addition to this specific case, fu
will provide the size of the inner elements any time an argument ends with /
.
fu . # Size of current folder
fu ./ # Size of every file / folder in current folder
fu ./* # Size of every file / folder in current folder
fu ./**/* # Size of every file / folder inside the subfolders of the current one
Now, if a non existing file is passed to the CLI, it shows a generic rust message:
$ fu ./not-exist
Error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Instead, we should show a proper message using the red color.
This is one of the most complex parameters for this CLI. It will allow to limit the output entries based on different size expressions. There would be 3 options:
I still need to think on how this parameter will work or if it would be 3 separate params for simplicity.
Create the first test for the CLI and add the GitHub action to run tests. As a first step, I plan to add some unit testing around the functions I already created. Integration tests will come as a separate issue.
Good read: https://mattgathu.dev/2017/10/01/testing-rust-cli-apps.html
This command will help to identify the current CLI version. We should inject this value while compiling the project. Adding the repo commit would be useful too.
This will allow better integrations with other tools. By default, the output format is the listing one.
By default, fu
will return a colorize otuput based on the size of the different files in disk. I will start with the following scale, but it may change in the future.
aquamarine
: 0 - 1Kbblue
: 1Kb - 128Mbpurple
: 128Mb - 512Mborange
: 512Mb - 1Gbred
: more than 1GbThe --no-colors
parameter will disable the colorized output.
As a first test, I would add a GitHub action to build the CLI without any issue.
The README file should include an introduction, usage and installation (TODO). I will complete it with more features later on, but at least I have a basic one.
This is the last step to release the v1.0.0! I need to:
In the future, this will be automated.
This parameter will limit the number of entries to the (--top k
) k
number of heaviest files / folders. This parameter is completely optional and only affects to the number of rows.
Currently, files have different indentation. To keep it consistent, I plan to add an .editorconfig
file to ensure the indentation is consistent across Rust files. In the future I may add more configuration parameters.
More info about editor config on: https://editorconfig.org/
There's an error under certain circumstances that causes the CLI to fail due to:
$ fu ./
Error: Os { code: 62, kind: FilesystemLoop, message: "Too many levels of symbolic links" }
I still need to debug the root cause but I'm going to open this issue for tracking.
Add the instructions to install the CLI in the different operating systems.
This section will include the total sum of the different entries. This result can be disabled using the --no-total
flag
This parameter will change the ordering of the different entities in the list by its size. This is useful to visualize the heaviest elements in a folder quickly.
fu --sort ./
This optional parameter allows to ignore a specific folder or file. This is specially useful when using with the --top
option as it allows you to delete already known foldesr from the computation.
fu --ignore node_modules
fu --ignore target --top 3
Create a Makefile
to somplify some common tasks such as build, test and run.
To improve the README file, let's add the GitHub actions and release badge and a screenshot.
Most MacOS developers are used to install the different CLIs thye use through brew
. Downloading it directly via curl
usually require manual intervention to allow the execution of the CLI, so having a brew formula is very convenient.
First, I will create a local formula as merging it in the official repo requires an approval policy.
I tried to add fu
as https://scoop.sh package to install under windows,
unfortunately
https://github.com/Angelmmiguel/fu/releases/download/1.0.0/fu-x86_64-pc-windows-gnu.tar.gz
this is a just .tar instead of gzipped tar
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.