Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
kattis-command
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Henke
kattis-command
Commits
b05e99ae
There was a problem fetching the pipeline summary.
Commit
b05e99ae
authored
Mar 12, 2018
by
Henke
Browse files
Options
Downloads
Patches
Plain Diff
fix issue
#40
Now there is a compile command for the cli
parent
8dd96e15
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
kattcmd/commands/compile.py
+50
-0
50 additions, 0 deletions
kattcmd/commands/compile.py
kattcmd/commands/latest.py
+4
-0
4 additions, 0 deletions
kattcmd/commands/latest.py
with
54 additions
and
0 deletions
kattcmd/commands/compile.py
+
50
−
0
View file @
b05e99ae
import
os
import
os
import
shutil
import
shutil
import
click
def
_GetBuildFolder
(
bus
):
def
_GetBuildFolder
(
bus
):
...
@@ -121,3 +122,52 @@ def Init(bus):
...
@@ -121,3 +122,52 @@ def Init(bus):
bus
.
provide
(
'
kattcmd:compile:python
'
,
CompilePython
)
bus
.
provide
(
'
kattcmd:compile:python
'
,
CompilePython
)
bus
.
provide
(
'
kattcmd:compile:cpp-command
'
,
FindCppCompileCommand
)
bus
.
provide
(
'
kattcmd:compile:cpp-command
'
,
FindCppCompileCommand
)
def
CLI
(
bus
,
parent
):
def
OnCppCompiled
(
binary
):
click
.
echo
(
'
Placed binary at {}
'
.
format
(
binary
))
def
OnCppCompileFailed
(
compile_command
):
click
.
secho
(
'
Could not compile with
"
{}
"'
.
format
(
compile_command
),
fg
=
'
red
'
)
def
OnPythonCompiled
(
paths
):
paths
=
list
(
map
(
os
.
path
.
relpath
,
paths
))
click
.
echo
(
'
Copied to following paths {}
'
.
format
(
paths
))
def
OnNoFiles
(
problemname
):
click
.
secho
(
'
Could not find any
"
compilable
"
items for
"
{}
"'
.
format
(
problemname
),
fg
=
'
red
'
)
click
.
echo
(
'
Exiting
'
)
exit
(
1
)
@parent.command
()
@click.argument
(
'
name
'
)
def
compile
(
name
):
'''
Compile your solution to a problem.
Will compile your solution and put it inside the build
folder. If you use an interpreted language then it will copy
it instead.
This command is useful if you want to run the code yourself
against some specific input.
'''
bus
.
listen
(
'
kattcmd:compile:cpp-compiled
'
,
OnCppCompiled
)
bus
.
listen
(
'
kattcmd:compile:cpp-compile-failed
'
,
OnCppCompileFailed
)
bus
.
listen
(
'
kattcmd:compile:python-compiled
'
,
OnPythonCompiled
)
bus
.
listen
(
'
kattcmd:latest:no-files
'
,
OnNoFiles
)
value
=
bus
.
call
(
'
kattcmd:latest
'
,
bus
,
name
)
if
not
value
:
click
.
secho
(
'
Could not determine what you worked on previously
'
,
fg
=
'
red
'
)
click
.
echo
(
'
Exiting
'
)
return
None
type
,
_
=
value
if
type
==
'
python
'
:
bus
.
call
(
'
kattcmd:compile:python
'
,
bus
,
name
)
elif
type
==
'
cpp
'
:
bus
.
call
(
'
kattcmd:compile:cpp
'
,
bus
,
name
)
else
:
raise
ValueError
(
'
{} is not an implemented type
'
.
format
(
type
))
This diff is collapsed.
Click to expand it.
kattcmd/commands/latest.py
+
4
−
0
View file @
b05e99ae
...
@@ -32,6 +32,10 @@ and the associated files.'''
...
@@ -32,6 +32,10 @@ and the associated files.'''
home
=
bus
.
call
(
'
kattcmd:find-root
'
,
bus
)
home
=
bus
.
call
(
'
kattcmd:find-root
'
,
bus
)
problempath
=
os
.
path
.
join
(
home
,
'
kattis
'
,
problemname
)
problempath
=
os
.
path
.
join
(
home
,
'
kattis
'
,
problemname
)
if
not
os
.
path
.
exists
(
problempath
):
bus
.
call
(
'
kattcmd:latest:no-files
'
,
problemname
)
return
None
items
=
[
os
.
path
.
join
(
problempath
,
item
)
for
item
in
os
.
listdir
(
problempath
)]
items
=
[
os
.
path
.
join
(
problempath
,
item
)
for
item
in
os
.
listdir
(
problempath
)]
with_date
=
[(
os
.
path
.
getmtime
(
fpath
),
fpath
)
for
fpath
in
items
]
with_date
=
[(
os
.
path
.
getmtime
(
fpath
),
fpath
)
for
fpath
in
items
]
latest_first
=
reversed
(
sorted
(
with_date
))
latest_first
=
reversed
(
sorted
(
with_date
))
...
...
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