Giter Club home page Giter Club logo

maid-cli's Introduction

logo

maid-cleaning-cli

Maid - Your Lightweight CLI Utility for Keeping Directories Clean and Structured

Organizing directories can become messy over time. Maid is here to help. Define where files should go, and Maid will take care of it. Listing files, moving files, and maintaining clean directories - Maid is here for you!

Installation

npm install maid-cleaning-cli -g

Usage

Listing Contents of a Directory

To list all files and sub-directories in a certain directory, just navigate to said directory and tell maid to list:

maid list

The output will be color-coded. Blue represents files, and red represents sub-directories.

logo

To specify what to list, list accepts two flags:

  • -f or --files to show files
  • -d or --dirs to show directories

When using the flags, a color-coded headline will be printed above the actual result. Either Directories in current directory or Files in current directory.

Cleaning a directory

To clean a directory, just simply navigate to the messy directory and tell maid to clean:

maid clean

By default maid will not start cleaining without you instructing what needs cleaing and what must not be cleaned. For the clean command to take action, a .maidrc-file is required. If no config is present, an error with instructions will be printed - so don't worry, maid won't go ahead and move your files around without you knowing what you are doing.

Example

With the following rule in my .maidrc:

---
cleanRules:
  - { pattern: "^Test", fileExtension: ".txt", dirName: "test_txt_files" }

Every file with a name starting with "Test" and a file extention of ".txt" will be moved to a folder test_txt_files.

logo

.maidrc Configuration

To instruct Maid on what to clean, create a .maidrc configuration file on your machine. Maid will use it when running.

For now, the config file only supports one property: cleanRules.

cleanRules is an array of objects that define the rules for Maid to clean. Each object represents one rule, indicating what to clean and under which conditions.

  • pattern (String): A regular expression to describe how the filename should look (e.g. "^Test" will filter all files starting with "Test")
  • fileExtension (String-Array): A list of file extension to limit the files to be cleaned (e.g. ".png" - include the .)
  • applyInDir (String-Array): A list of paths in which the rule can be applied. If applyInDir is no present, the rule is global and applicable in every folder
  • dirName (String): When cleaning files, maid will move them to a folder, that can be specified with this string (e.g. "/screenshots/images")

pattern, fileExtension and applyInDir will be evaluated with AND-logic, so the rule

{
  "pattern": "^Testfile",
  "fileExtension": [".png"],
  "dirName": "testfiles",
  "applyInDir": ["/Users/<username>/Desktop"]
}

will only move files to a folder called testfiles, if the following conditions are all met:

  • if the filename starts with "Testfile"
  • if the file has the extension .png
  • the current directory is /Users/<username>/Desktop

If neither pattern nor fileExtension is defined, the rule will not trigger and do nothing.

git repo safeguard

As an additional safeguard to prevent accidentally messing up the structure of git repositories, maid has a build in check when running clean. If current directory is a git repository, maid will ask if you wish to continue.

logo

Getting Information about Saved Configuration

To retrieve information about the saved .maidrc configuration, use the following command:

maid config

For specific information, use these flags:

  • p or --path: Get the path to the config file
  • r or --cleanRules: Get all saved rules from the config
  • d or --rulesForDir: Get rules specific to the current directory

Creating Configuration

If no configuration is present, maid can even initiate configuration for you, just call config with the flag -i or --init

maid config --init

This command will guide you through the process of creating a .maidrc configuration file. If the configuration file already exists, the command will let you know.

Adding a Rule to Configuration

To add a rule to the configuration, use the following command:

maid config --addRule

This command will prompt you to enter details for the rule you want to add. You will need to provide the following information:

  • Pattern (required if no fileExtension is specified): A regular expression to match filenames.
  • File Extension (required if no pattern is specified): A list of file extensions separated by commas (e.g., .txt, .jpg).
  • Apply in Directory (optional): Specify one or more directory paths where the rule should apply.
  • Directory Name (required): The name of the directory where matching files will be moved.

The addRule command allows you to define specific cleanup rules according to your needs.

Example:

Suppose you want to add a rule to move all files starting with "Report" and having the extensions .docx and .pdf to a directory called reports. You can use the following command:

maid config --addRule

Then provide the following information in the prompts:

  • Pattern: ^Report
  • File Extension: .docx, .pdf
  • Apply in Directory: (leave empty for global rule)
  • Directory Name: reports

logo

This will create a rule that moves files matching the specified pattern and extensions to the reports directory.

maid-cli's People

Contributors

mcmuellermilch avatar dependabot[bot] avatar

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.