grim/hgkeeper
Clone
Summary
Browse
Changes
Graph
Use Go 1.22 and update dependencies
default
tip
3 months ago, aklitzing
f33f223bc8fe
Use Go 1.22 and update dependencies
Reviewed at https://reviews.imfreedom.org/r/2949/
package
commands
import
(
"fmt"
"github.com/gliderlabs/ssh"
"keep.imfreedom.org/grim/hgkeeper/access"
"keep.imfreedom.org/grim/hgkeeper/hg"
)
type
Command
interface
{
Run
(
session
ssh
.
Session
,
username
string
)
error
}
func
Find
(
cmd
,
reposPath
string
)
(
Command
,
error
)
{
pcmd
,
values
,
err
:=
hg
.
ParseCommandArguments
(
cmd
)
if
err
!=
nil
{
return
nil
,
err
}
switch
pcmd
{
case
"hg serve"
:
return
NewServe
(
access
.
NormalizeRepo
(
reposPath
,
values
.
Hg
.
Repo
)),
nil
case
"hg init <repo>"
:
return
NewInit
(
access
.
NormalizeRepo
(
reposPath
,
values
.
Hg
.
Init
.
Repo
)),
nil
case
"rm <repo>"
:
return
NewRemove
(
access
.
NormalizeRepo
(
reposPath
,
values
.
Rm
.
Repo
)),
nil
default
:
return
nil
,
fmt
.
Errorf
(
"unknown command %s"
,
cmd
)
}
}