- Notifications
You must be signed in to change notification settings - Fork0
cat functions out of source code with autocomplete
License
dosyago/sourcecrop
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
sourcecrop is a command-line utility that displays code snippets (like functions, classes, or methods) from source files. It supports quick lookups, partial code extraction, and basic call analysis, making it easy to see what calls what in your JavaScript code. Other languages are on our roadmap.
ViaNPM:
$ npm i -g sourcecrop@latest
Or using git:
# Clone the repository$ git clone https://github.com/your-user/sourcecrop.git# Navigate into the project directory$cd sourcecrop# Run install script (might need sudo depending on your environment)$ ./install.sh
This should set up a symbolic link forsc
so you can use it anywhere.
$ sc<file> [name|calls-<name>|by-<name>|-listCallees|-listCallers]
- sc: Lists all declared functions and methods in
<file>
, suitable for autocompletion. - sc someFunction: Shows the code for
someFunction
. - sc calls-someFunction: Lists all functions that call
someFunction
. - sc by-someFunction: Lists all functions calledby
someFunction
. - sc -listCallees: Lists all functions called in
<file>
. - sc -listCallers: Lists all functions that call something else in
<file>
.
Examples:
List all declared functions:
$ sc app.jsmyFuncanotherFuncuntitled-161
Show code of a named function:
$ sc app.js myFunc// Displays thesource codefor thefunctionnamed myFunc
Find callers of a function:
$ sc app.js calls-myFunc// Lists all functions that call myFunc
Find callees used by a specific function:
$ sc app.js by-myFunc// Lists all functions that myFunc calls
List all function calls:
$ sc app.js -listCallees// Displays all distinctfunctioncalls foundin the file
For easier usage,sc
supports basic autocomplete when used in a bash-compatible shell. After installing, type:
$ sc app.js<TAB>
This should autocomplete declared function names or any recognized command likecalls-
andby-
.
We currently focus on JavaScript (ES modules). Support for additional languages is planned.
sourcecrop is licensed under theGNU Affero General Public License version 3, consistent with the copyright statement in the source.
© 2024 Cris (@o0101) and Dosyago Corp. This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.