Skip to content

MehmetMHY/fm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 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

  • shfmt
  • black
  • prettier
  • clang-format
  • gofmt (included with Go)

The install.sh script will attempt to install these for you using your system's package manager.

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 for macOS: GNU getopt is required and will be installed automatically. Add export PATH="$(brew --prefix gnu-getopt)/bin:$PATH" to your shell profile if needed.

Supported File Formats

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

Installation

  1. Clone the repository and go into it: git clone https://github.com/MehmetMHY/fm.git ; cd fm

  2. Run the install script to install and/or update fm: bash install.sh

  3. (optional) Uninstall fm, if you desire, by running the uninstall script: 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.

# 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 (Check)

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 .

Interactive Mode

For more control, you can use interactive mode with --interactive or -i. The script will prompt you for each file before formatting.

# run in interactive mode
fm -i .

You will be prompted with [y]es, [N]o, [a]ll, [q]uit.

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 .

About

A versatile CLI tool for formatting scripts across multiple programming languages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages