Code Monkey home page Code Monkey logo

fu's People

Contributors

angelmmiguel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

fu's Issues

Extract the calculation and printing logic to separate modules

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.

Add a graphical representation with the -g option

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.

Define the output format of the computation result

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.

Allow multiple argument formats

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 /.

Examples

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

Handle file not found errors properly

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.

Add an optional parameter to filter by size

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:

  • Bigger than
  • Smaller than
  • Between

I still need to think on how this parameter will work or if it would be 3 separate params for simplicity.

Colorize output and add --no-colors optional parameter

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 - 1Kb
  • blue: 1Kb - 128Mb
  • purple: 128Mb - 512Mb
  • orange: 512Mb - 1Gb
  • red: more than 1Gb

The --no-colors parameter will disable the colorized output.

Bump version to 1.0.0 and release it

This is the last step to release the v1.0.0! I need to:

  • Bump the version
  • Commit the change
  • Add the git tag
  • Create the release
  • Build the artifacts

In the future, this will be automated.

Add the --top optional parameter

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.

Issue with symbolik links

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 --sort property to sort a list by the size

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.

Examples

fu --sort ./

Upgrade clap to the latest version

Currently, fu is using an old clap version (3.1.0) and derive attributes. The goal is to update the library to the latest version (4.1.4) and the used newest version of the attributes.

Add the --ignore optional parameter

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.

Example

fu --ignore node_modules
fu --ignore target --top 3

Distribute MacOS fu through brew

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.