Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

cat functions out of source code with autocomplete

License

NotificationsYou must be signed in to change notification settings

dosyago/sourcecrop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sourcecrop in action

Sourcecrop (aka Spirit Catcher)

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.

Installation

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.

Usage

$ 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 forsomeFunction.
  • sc calls-someFunction: Lists all functions that callsomeFunction.
  • sc by-someFunction: Lists all functions calledbysomeFunction.
  • sc -listCallees: Lists all functions called in<file>.
  • sc -listCallers: Lists all functions that call something else in<file>.

Examples:

  1. List all declared functions:

    $ sc app.jsmyFuncanotherFuncuntitled-161
  2. Show code of a named function:

    $ sc app.js myFunc// Displays thesource codefor thefunctionnamed myFunc
  3. Find callers of a function:

    $ sc app.js calls-myFunc// Lists all functions that call myFunc
  4. Find callees used by a specific function:

    $ sc app.js by-myFunc// Lists all functions that myFunc calls
  5. List all function calls:

    $ sc app.js -listCallees// Displays all distinctfunctioncalls foundin the file

Shell Autocomplete

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-.

Roadmap

We currently focus on JavaScript (ES modules). Support for additional languages is planned.

License

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.

About

cat functions out of source code with autocomplete

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp