Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
shift
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eduardo Trujillo
shift
Commits
4fca6d50
Commit
4fca6d50
authored
4 years ago
by
Eduardo Trujillo
Browse files
Options
Downloads
Patches
Plain Diff
feat(Server): Allow listener port to be set in CLI options
parent
b4f9993d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Shift.hs
+19
-17
19 additions, 17 deletions
src/Shift.hs
src/Shift/CLI.hs
+8
-2
8 additions, 2 deletions
src/Shift/CLI.hs
src/Shift/Server.hs
+4
-3
4 additions, 3 deletions
src/Shift/Server.hs
with
31 additions
and
22 deletions
src/Shift.hs
+
19
−
17
View file @
4fca6d50
module
Shift
(
shiftMain
,
module
X
)
where
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE RecordWildCards #-}
import
Options.Applicative
module
Shift
(
shiftMain
,
module
X
,
)
where
import
Control.Lens
((
^.
))
import
Shift.CLI
as
X
import
Shift.Git
as
X
import
Options.Applicative
import
Shift.CLI
as
X
import
Shift.Git
as
X
import
Shift.Rendering
as
X
import
Shift.Types
as
X
import
Shift.Server
(
runServer
)
import
Shift.Types
as
X
-- | The main CLI entrypoint.
shiftMain
::
IO
()
...
...
@@ -20,12 +22,12 @@ shiftMain = do
case
currentOptions
^.
soCommand
of
GenerateCommand
->
tempMain
currentOptions
ServeCommand
->
runServer
currentOptions
ServeCommand
{
_scPort
,
..
}
->
runServer
_scPort
currentOptions
where
opts
=
info
(
helper
<*>
shiftOptions
)
(
fullDesc
<>
progDesc
"Execute the given COMMAND"
<>
header
"shift - A change log generator"
)
opts
=
info
(
helper
<*>
shiftOptions
)
(
fullDesc
<>
progDesc
"Execute the given COMMAND"
<>
header
"shift - A change log generator"
)
This diff is collapsed.
Click to expand it.
src/Shift/CLI.hs
+
8
−
2
View file @
4fca6d50
...
...
@@ -19,7 +19,7 @@ data ShiftOptions = ShiftOptions
}
deriving
(
Show
,
Eq
)
data
ShiftCommand
=
GenerateCommand
|
ServeCommand
deriving
(
Show
,
Eq
,
Enum
)
data
ShiftCommand
=
GenerateCommand
|
ServeCommand
{
_scPort
::
Maybe
Int
}
deriving
(
Show
,
Eq
)
data
HostingType
=
GitHubType
|
GitType
deriving
(
Show
,
Eq
,
Enum
)
...
...
@@ -85,7 +85,13 @@ shiftCommand =
)
<>
command
"serve"
(
info
(
pure
ServeCommand
)
(
progDesc
"Start UI server"
))
(
info
(
ServeCommand
<$>
optional
(
option
auto
(
long
"port"
<>
help
"Web server listener port"
))
)
(
progDesc
"Start UI server"
)
)
hostingType
::
ReadM
HostingType
hostingType
=
eitherReader
$
\
case
...
...
This diff is collapsed.
Click to expand it.
src/Shift/Server.hs
+
4
−
3
View file @
4fca6d50
...
...
@@ -5,13 +5,14 @@ module Shift.Server (runServer) where
import
CMarkGFM
(
commonmarkToHtml
,
nodeToCommonmark
,
nodeToHtml
)
import
Control.Monad.IO.Class
(
MonadIO
(
liftIO
))
import
Data.Maybe
(
fromMaybe
)
import
Data.Text.Lazy
(
fromChunks
)
import
Shift.CLI
(
ShiftOptions
)
import
Shift.Git
(
renderToNode
)
import
Web.Scotty
(
rescue
,
rescue
,
get
,
html
,
param
,
scotty
,
text
)
import
Web.Scotty
(
get
,
html
,
param
,
rescue
,
scotty
,
text
)
runServer
::
ShiftOptions
->
IO
()
runServer
options
=
scotty
3000
$
runServer
::
Maybe
Int
->
ShiftOptions
->
IO
()
runServer
port
options
=
scotty
(
fromMaybe
3000
port
)
$
get
"/"
$
do
(
asMarkdown
::
Bool
)
<-
param
"as_markdown"
`
rescue
`
(
\
_
->
pure
False
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment