Giter Site home page Giter Site logo

altr's Introduction

Altr: Smart CLI Refactoring Tool

Overview

Altr is a robust command-line refactoring tool designed to effortlessly enhance your codebase while maintaining your preferred casing styles.

How to Use

Execute Altr with the following command:

altr <termToReplace> <replacementTerm> -f <path>

Example

Let's take a look at a practical scenario using a file named programmer.js, where we want to rename "programmer" to "rustProgrammer".

const programmer = new Programmer(Adam);

function getProgrammerName(programmer: Programmer) {
    return programmer.name;
}

// Updating the name for the PROGRAMMER
function setProgrammerName(name: string) {
    programmer.name = name; 
}

Executing the command:

altr programmer rustProgrammer -f programmer.js

Results in the following updated file:

const rustProgrammer = new RustProgrammer(Adam);

function getRustProgrammerName(rustProgrammer: RustProgrammer) {
    return rustProgrammer.name;
}

// Updating the name for the RUST_PROGRAMMER
function setRustProgrammerName(name: string) {
    rustProgrammer.name = name; 
}

Altr intelligently handles the replacement, considering the casing styles of both the original term and the specified replacement term. For instance, if we run:

altr programmer rust_programmer -f programmer.js

The tool adjusts the file accordingly:

const rust_programmer = new RustProgrammer(Adam);

function getRustProgrammerName(rust_programmer: RustProgrammer) {
    return rust_programmer.name;
}

// Updating the name for the RUST_PROGRAMMER
function setRustProgrammerName(name: string) {
    rust_programmer.name = name; 
}

Notice how Altr adapts to the casing requirements of the replacement term.

IO Support

Altr supports taking in input from stdin and passing it to stdout

$ echo "programmer" | altr programmer rust_programmer
$ rust_programmer

You can also specify the output location

altr programmer rust_programmer -f programmer.js -o rust-programmer.js

You can use "-" as path to indicate stdin or stdout as well

Installation

Altr is easily installed using cargo:

cargo install altr

altr's People

Contributors

jnsahaj avatar sahaj-myhq 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.