Recent Changes - Search:

Home Page


Main

Downloads
Windows
macOS
Linux (via apt / rpm )
Linux wxWidgets
Release Notes

Wiki
Documentation
FAQ

Build CodeLite
Linux
Windows
macOS

Devs
Debug CodeLite Linux
Building Clang
Build wxWidgets (MSW)
Coding Guidelines
Create a Plugin

Codelite-cli


About


codelite-cli is a minimal tool which exposes various CodeLite operations to the command line The current exposed API is limited and will be extended in the future. The idea behind codelite-cli is to provide an easy to use API that can be executed by other editors or CodeLite itself (i.e. the SFTP plugin)

Usage


Run codelite-cli -h to see the usage command line Basic commands are in the form of:

codelite-cli <command> <command-options>

The options are in the form of JSON object, see below for more details.

API


list


List a directory content

Syntax:

codelite-cli list '{"path":"/path/to/folder"}'

Options:

  • path folder to list

Example output:

$bin/codelite-cli list '{"path":"/home/eran/devl/codelite/codelite-cli/build-debug"}'
[{
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/bin",
  "type": "dir"
 }, {
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/CMakeCache.txt",
  "type": "file"
 }, {
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/lib",
  "type": "dir"
 }, {
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/Makefile",
  "type": "file"
 }, {
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/compile_commands.json",
  "type": "file"
 }, {
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/CMakeFiles",
  "type": "dir"
 }, {
  "path": "/home/eran/devl/codelite/codelite-cli/build-debug/cmake_install.cmake",
  "type": "file"
 }]

each entry in the output JSON array, is marked with the field type to mark its type (folder or file)

find


Perform a find-in-files operation on a folder

Syntax:

codelite-cli find '{"path":"/home/eran/devl/codelite/codelitephp", "word":true, "case":true, "mask":"*.cpp", "what":"wxDELETE"}'

Options:

  • path folder to search in
  • word find a whole words
  • case use case sensitive search
  • mask semi colon list of file masking to search e.g. *cpp;*.h;*.txt
  • what the string to search

Example:

$bin/codelite-cli find '{"path":"/home/eran/devl/codelite/codelite-cli", "what":"HasFlag", "case":true, "word":true, "mask":"*.cpp;*.h"}'
[{
  "file": "/home/eran/devl/codelite/codelite-cli/csConfig.h",
  "line": 26,
  "col": 9,
  "pos": 404,
  "pattern": "    bool HasFlag(eConfigOption flag) const { return m_flags & flag; }",
  "len": 7,
  "flags": 3,
  "columnInChars": 9,
  "lenInChars": 7
 }, {
  "file": "/home/eran/devl/codelite/codelite-cli/csConfig.h",
  "line": 38,
  "col": 39,
  "pos": 909,
  "pattern": "    bool IsPrettyJSON() const { return HasFlag(kPrettyJSON); }",
  "len": 7,
  "flags": 3,
  "columnInChars": 39,
  "lenInChars": 7
 }, {
  "filesScanned": 38,
  "matchesFound": 2,
  "elapsed": 118,
  "failedFiles": [],
  "findWhat": "HasFlag",
  "replaceWith": ""
 }]

The result is in the form of JSON array containing list of objects. The last entry in the output array is the search summary.

parse


Parse all files in a folder recursively that matches the file mask provided

Syntax: codelite-cli parse '{"path":"/home/eran/devl/codelite/codelite-cli", "lang":"php", "mask":"*.php", "symbols-path":"/tmp/my_symbols.db"}'

Options:

  • path folder or file to parse
  • lang parser language, current values supported:
    • php
  • mask semi colon list of file masking to search and parse e.g. *.php;*.inc
  • symbols-path this field is optional. The location to store the symbols parsed. If this field is omitted, the symbols are stored in folder's path.

This command does not produce an output. Instead, you should check exit code (this is always a good idea...)

code-complete


Offers code completion in a given location in a file

Syntax:

codelite-cli code-complete '{"path":"/home/eran/devl/php/src/data.php", "unsaved-buffer-path":"/tmp/data.php.tmp", "lang":"php", "position":677, "symbols-path":"/tmp/my_symbols.db"}'

Options:

  • path file to code complete
  • unsaved-buffer-path OPTIONAL if your buffer is dirty, you can save the content of the dirty buffer into a temporary file and tell codelite-cli to parse this file instead
  • lang parser language, current values supported:
    • php
  • position this points to the location where a code completion should be computed. the position is zero based, from the start of the file
  • symbols-path the symbols cache (see 'parse' command)

Example:

$codelite-cli code-complete '{"lang":"php", "path":"/home/eran/devl/test_php/test.php", "position":128, "symbols-path":"/tmp/test_php.db"}'
[{
  "type": "f",
  "file": "/home/eran/devl/test_php/test.php",
  "name": "foo",
  "fullname": "\\MyClass\\foo",
  "doc": "",
  "line": 4,
  "col": 0,
  "flags": 2,
  "returns": "",
  "signature": "()"
 }, {
  "type": "f",
  "file": "/home/eran/devl/test_php/test.php",
  "name": "bar",
  "fullname": "\\MyClass\\bar",
  "doc": "",
  "line": 5,
  "col": 0,
  "flags": 2,
  "returns": "",
  "signature": "()"
 }, {
  "type": "f",
  "file": "/home/eran/devl/test_php/test.php",
  "name": "baz",
  "fullname": "\\MyClass\\baz",
  "doc": "",
  "line": 6,
  "col": 0,
  "flags": 2,
  "returns": "",
  "signature": "()"
 }]

This API returns list of possible code completion members.

Output fields:

  • type - can be one of:
    • f - for function
    • c - class
    • v - variable
    • n - namespace
    • k - keyword
    • a - alias. An alias is generated by statements like using \A\B\MyClass MyClass
  • file the file where this entry is defined
  • line the line number for the definition
  • doc if this function has a PHP doc comment, include it here
  • col always 0
  • flags the entry bit fields. ORed. The flags changes their meaning depends on the context.

When the entry is of type 'function' ('f'), these are the possible flag values:

// Function flags
enum {
    kFunc_Public = (1 << 1),
    kFunc_Private = (1 << 2),
    kFunc_Protected = (1 << 3),
    kFunc_Final = (1 << 4),
    kFunc_Static = (1 << 5),
    kFunc_Abstract = (1 << 6),
    kFunc_ReturnReference = (1 << 7),
};

When the entry is of type 'variable' ('v'), these are the possible values:

enum {
    kVar_Public = (1 << 1),
    kVar_Private = (1 << 2),
    kVar_Protected = (1 << 3),
    kVar_Member = (1 << 4),
    kVar_Reference = (1 << 5),
    kVar_Const = (1 << 6),
    kVar_FunctionArg = (1 << 7),
    kVar_Static = (1 << 8),
    kVar_Define = (1 << 9),
};
Edit - History - Print - Recent Changes - Search
Page last modified on July 29, 2018, at 04:00 PM