Just drop a Pull Request :)
- Use LF. Set up your Git settings with this:
git config --global core.autocrlf false
and check if it is OK bygit config --global core.autocrlf
. It need to returnfalse
or nothing. - Use spaces, size 4
- Navigate to
utils.lua
, - change
os
variable in top ofutils.lua
, - find unimplemented portion of code,
- add
if
statement for new platform. - Example:
local os = "your_os"
-- bunch of code
function util.some_function(path)
if os == "windows" then
-- code
elseif os == "linux" then
-- code
elseif os == "your_os" then -- new part of the code
-- code
else
-- code
end
end
- In
functions
folder create new file which is called same as command name - Open
utils.lua
and inCommands
table add name of command (don't worry about alphabetical order, Termi-Lua will sort it) - Follow example:
local name_of_command_which_you_put_in_Commands_table = {}
function name_of_command_which_you_put_in_Commands_table.Run(arg)
--- functions which name is `Run` are main functions for command
--- your code
end
return name_of_command_which_you_put_in_Commands_table
- Don't forget on
arg
which istable
and argument for functions
- Line width much be at most 100 characters.
- Use spaces, spaces size MUST BE 4!
When a function call does not fit onto a line, align arguments like this:
FunctionCall(arg1,
arg2,
arg3);
When making new functions, declare return parameter and all params in utils.lua
Right:
--- Return how many elements table (list) has
--- @param str string
--- @return string
function example(str)
return str
end
Wrong:
function example(str)
return str
end
- Place spaces around binary and ternary operators.
Right: a = b + c;
Wrong: a=b+c;
- Do not place spaces between a function and its parentheses, or between a parenthesis and its content.
Right:
func(a, b);
Wrong:
func (a, b);
func( a, b );
- Don’t use inverse logic in control clauses.
Right: if i == 1
Wrong: if 1 == i
Part called "Naming" is written by ringwormGO itself
- Name a function by capital letter.
Right: void Test();
Wrong: void test();
- Name tables with cappital letter and variables which lowercase letter
Right:
local Table = {};
local number;
Wrong:
local table = {};
local Number;
Part called "Commenting" is written by ringwormGO itself
- For comments on top of file use this:
---
--- @author John
--- @PROJECT: Termi-Lua
--- @LICENSE: ringwormGO General License 1.0 | (RGL) 2022
--- @DESCRIPTION: Example
---
- https://reactos.org/wiki/Coding_Style (some parts are modificeted)