Skip to content

Commit

Permalink
refactor: simplify command arg handling
Browse files Browse the repository at this point in the history
  • Loading branch information
2KAbhishek committed Nov 10, 2024
1 parent c5e2de3 commit 4d52284
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lua/octohub/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ local M = {}

M.setup = function()
vim.api.nvim_create_user_command('OctoRepos', function(opts)
local args = vim.split(opts.args, ' ')
local user_arg, sort_arg, type_arg = '', '', ''

for _, arg in ipairs(args) do
if arg:sub(1, 5) == 'sort:' then
for _, arg in ipairs(vim.split(opts.args, ' ')) do
if arg:match('^sort:') then
sort_arg = arg:sub(6)
elseif arg:sub(1, 5) == 'type:' then
elseif arg:match('^type:') then
type_arg = arg:sub(6)
else
user_arg = arg
Expand Down Expand Up @@ -41,7 +40,7 @@ M.setup = function()
local user_arg, count_arg = '', ''

for _, arg in ipairs(args) do
if arg:sub(1, 6) == 'count:' then
if arg:match('^count:') then
count_arg = arg:sub(7)
else
user_arg = arg
Expand Down

0 comments on commit 4d52284

Please sign in to comment.