Skip to content

MehmetMHY/fm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FM

Overview

fm is a CLI tool currently in early development, designed to format scripts across various projects. This tool offers more control over formatting compared to relying on an IDE. While it's still in development, it's fully usable! If you're interested in contributing, feel free to fork the repo and submit a PR.

Requirements

The install.sh script will attempt to install these for you using your system's package manager. If fm is already installed, running install.sh will update your existing dependencies instead.

Supported Operating Systems

  • macOS (Homebrew)
  • Debian/Ubuntu (APT)
  • RHEL/CentOS (YUM)
  • Fedora (DNF)
  • openSUSE (Zypper)
  • Arch Linux (Pacman)
  • Gentoo (Portage)
  • Void Linux (XBPS)
  • Android/Termux (pkg)

NOTE: On macOS, GNU getopt is required and will be installed automatically. The script will auto-detect Homebrew's installation, so no manual PATH configuration is needed in most cases.

Supported File Formats

.py
.sh
.bash
.dash
.ksh
.zsh
.js
.jsx
.ts
.tsx
.json
.md
.yml
.yaml
.graphql
.vue
.scss
.less
.c
.cpp
.h
.hpp
.m
.mm
.java
.go
.rs
.swift

Future Formatters

There is consideration for supporting additional languages based on community demand. The formatters that are being heavily considered right now are the following:

Support for formatting HTML and CSS files was heavily considered, but no suitable solution exists that meets the project's standards. So, sadly, support for HTML and CSS will not happen any time soon.

Installation

Quick Install

# clone the repository and navigate into it
git clone https://github.com/MehmetMHY/fm.git && cd fm

# run the install script (or update dependencies if already installed)
bash install.sh

Custom Install / Interactive Update

This is optional, but for a more controlled installation or update where you're prompted for each dependency:

bash install.sh -w

Or using the long form:

bash install.sh --wizard

Uninstall

This is optional, but if you want to remove fm from your system:

bash uninstall.sh

Usage

To see all options, use the help flag:

fm -h

Basic Usage

To format an entire directory:

fm /path/to/dir

To format a single file:

fm path/to/filename

Format current directory by default:

fm

Advanced Usage

Selecting Languages

You can specify which languages to format using the -l or --languages flag. Provide a comma-separated list of languages.

Available languages: bash, python, javascript, clang, go, rust, swift.

# format only Python and Bash files in the current directory
fm -l 'python,bash' .

Ignoring Files and Directories

You can ignore specific files or directories using the -I or --ignore flag. You can use this flag multiple times. It accepts glob patterns.

# ignore the node_modules and dist directories
fm -I 'node_modules/*' -I 'dist/*' .

# ignore all .log files
fm --ignore '*.log' .

Dry Run Mode

To see which files would be changed without actually modifying them, use the --check or -c flag. This is useful for CI checks or pre-commit hooks.

# check for files that need formatting
fm --check .

Parallel Processing

To speed up formatting on large projects, you can run the formatter on multiple files in parallel using the --workers or -w flag.

# run with 4 parallel workers
fm --workers 4 .

Disabling .gitignore

To format files that are listed in your .gitignore file, use the --no-gitignore flag.

# format all files, including those in .gitignore
fm --no-gitignore .

License

This project is licensed under the GNU General Public License v3.0.

About

A versatile CLI tool for formatting scripts across multiple programming languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages