Provide auto-completion for the crystal language ( racer like )
For Emacs integration see TechMagister/emacs-cracker
For Sublime Text integration see TechMagister/CrystalAutoComplete
Start the server
cracker server /path/to/crystal/source
And query :
$ cracker client --help
Options:
--add-path Source path to add to completion database
-p Server port
(default: 1234)
--starts-with format : Class#method for instance method
Class.method for class method
--context Take a context in stdin
--stop-server Stop the server
-h, --help show this help
Example :
$ cracker client --starts-with Array.e
Outputs all the Array class methods starting with e :
{
"status": "success",
"results": [
{
"name": "Array.each_product(arrays)",
"file": "/path/to/crystal/source/array.cr",
"location": ":1138:3",
"type": "Function",
"signature": "def self.each_product(arrays)"
},
{
"name": "Array.each_product(arrays : Array)",
"file": "/path/to/crystal/source/array.cr",
"location": ":1162:3",
"type": "Function",
"signature": "def self.each_product(*arrays : Array)"
}
]
}
$ cracker client --starts-with Array#e
Outputs all the Array instance methods starting with e :
{
"status": "success",
"results": [
{
"name": "Array#each_permutation(size : Int = self.size)",
"file": "/path/to/crystal/source/array.cr",
"location": ":964:3",
"type": "Function",
"signature": "def each_permutation(size : Int = self.size)"
},
...
{
"name": "Array#each_repeated_permutation(size : Int = self.size)",
"file": "/path/to/crystal/source/array.cr",
"location": ":1176:3",
"type": "Function",
"signature": "def each_repeated_permutation(size : Int = self.size)"
}
]
}
$ echo "@test : String\n@test.to_f" | cracker client --context
{
"status": "success",
"results": [
{
"name": "String#to_f(whitespace = true,strict = true)",
"file": "/home/arnaud/workspace/repos/crystal/src/string.cr",
"location": ":608:3",
"type": "Function",
"signature": "def to_f(whitespace = true, strict = true)"
},
{
"name": "String#to_f?(whitespace = true,strict = true)",
"file": "/home/arnaud/workspace/repos/crystal/src/string.cr",
"location": ":626:3",
"type": "Function",
"signature": "def to_f?(whitespace = true, strict = true)"
},
{
"name": "String#to_f32(whitespace = true,strict = true)",
"file": "/home/arnaud/workspace/repos/crystal/src/string.cr",
"location": ":631:3",
"type": "Function",
"signature": "def to_f32(whitespace = true, strict = true)"
},
{
"name": "String#to_f32?(whitespace = true,strict = true)",
"file": "/home/arnaud/workspace/repos/crystal/src/string.cr",
"location": ":636:3",
"type": "Function",
"signature": "def to_f32?(whitespace = true, strict = true)"
},
{
"name": "String#to_f64(whitespace = true,strict = true)",
"file": "/home/arnaud/workspace/repos/crystal/src/string.cr",
"location": ":644:3",
"type": "Function",
"signature": "def to_f64(whitespace = true, strict = true)"
},
{
"name": "String#to_f64?(whitespace = true,strict = true)",
"file": "/home/arnaud/workspace/repos/crystal/src/string.cr",
"location": ":649:3",
"type": "Function",
"signature": "def to_f64?(whitespace = true, strict = true)"
}
]
}