-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
163 changed files
with
10,249 additions
and
8,231 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
local console = require('vgit.core.console') | ||
local Object = require('vgit.core.Object') | ||
|
||
local Command = Object:extend() | ||
|
||
function Command:new() | ||
return setmetatable({}, Command) | ||
end | ||
|
||
function Command:execute(command, ...) | ||
local vgit = require('vgit') | ||
if not command then | ||
return | ||
end | ||
local starts_with = command:sub(1, 1) | ||
if | ||
starts_with == '_' | ||
or not vgit[command] | ||
or not type(vgit[command]) == 'function' | ||
then | ||
console.error(string.format('Invalid VGit command %s', command)) | ||
return | ||
end | ||
return vgit[command](...) | ||
end | ||
|
||
function Command:list(arglead, line) | ||
local vgit = require('vgit') | ||
local parsed_line = #vim.split(line, '%s+') | ||
local matches = {} | ||
if parsed_line == 2 then | ||
for name, func in pairs(vgit) do | ||
if | ||
not vim.startswith(name, '_') | ||
and vim.startswith(name, arglead) | ||
and type(func) == 'function' | ||
then | ||
matches[#matches + 1] = name | ||
end | ||
end | ||
end | ||
return matches | ||
end | ||
|
||
return Command |
Oops, something went wrong.