Codeshift is a command-line tool to translate and transform source code files between programming languages.
stdout
Clone the repository with Git:
git clone https://github.com/uday-rana/codeshift.git
In the repository's root directory (where package.json
is located), run npm install
:
cd codeshift/
npm install
To be able to run the program without prefixing node
, run npm install -g .
or npm link
within the project directory:
npm install -g .
Create a file called .env
by copying the .env.example
file
Add your API key, preferred base URL, and preferred model. It should look similar to the example below:
https://api.openai.com/v1
https://openrouter.ai/api/v1
https://api.groq.com/openai/v1
.# .env
API_KEY=YOUR_API_KEY_HERE
BASE_URL=https://api.groq.com/openai/v1
MODEL=llama3-8b-8192
codeshift [options] <output-language> <input-files...>
<output-language>
: The desired language to convert source files to<input-files...>
: Paths to the source files, separated by spaces-o, --output
: Specify filename to write output to-t, --token-usage
: Display the number of tokens used by the AI for processing-h, --help
: Display the help message explaining usage, options, and arguments-v, --version
: Display the program name and version number# Converts a JavaScript file (index.js) to Go, saving the output in index.go
codeshift -o index.go go examples/index.js
See CONTRIBUTING.md
This project is licensed under the MIT License. See the LICENSE file for more details.