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
3c6b86c5
There was a problem fetching the pipeline summary.
Commit
3c6b86c5
authored
Mar 16, 2018
by
Henke
Browse files
Options
Downloads
Patches
Plain Diff
Add some ending words for the plugin tutorial
parent
c9653b52
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/writing-a-plugin.md
+38
-2
38 additions, 2 deletions
docs/writing-a-plugin.md
with
38 additions
and
2 deletions
docs/writing-a-plugin.md
+
38
−
2
View file @
3c6b86c5
...
@@ -127,8 +127,44 @@ def CLI(bus, parent):
...
@@ -127,8 +127,44 @@ def CLI(bus, parent):
@click.argument
(
'
libfile
'
)
@click.argument
(
'
libfile
'
)
@click.argument
(
'
problem
'
)
@click.argument
(
'
problem
'
)
def
libcp
(
libfile
,
problem
):
def
libcp
(
libfile
,
problem
):
'''
my docstring
'''
pass
pass
```
```
Now we have created the command
`kattcmd libcp LIBFILE PROBLEM`
. Both passed as
Now we have created the command
`kattcmd libcp LIBFILE PROBLEM`
. Both
strings to the
`libcp`
function.
passed as strings to the
`libcp`
function. Click will automatically
add the command as a visible subcommand when running
`kattcmd`
and
running
`kattcmd libcp --help`
will display the help message for it,
which is the docstring for the function.
If we combine our implementation with the code above we will have
finished our plugin! The final plugin looks like this:
```
python
import
click
import
os
import
shutil
def
CLI
(
bus
,
parent
):
@parent.command
()
@click.argument
(
'
libfile
'
)
@click.argument
(
'
problem
'
)
def
libcp
(
libfile
,
problem
):
'''
Copies a library file to a problem folder
'''
try
:
home
=
bus
.
call
(
'
kattcmd:find-root
'
,
bus
)
except
Exception
as
e
:
print
(
'
User is not in a kattis directory
'
,
e
)
exit
(
1
)
src
=
os
.
path
.
join
(
home
,
'
library
'
,
libfile
)
dst
=
os
.
path
.
join
(
home
,
'
kattis
'
,
problem
,
libfile
)
shutil
.
copyfile
(
src
,
dst
)
```
That is all that you should need to get started with plugin
development for
`kattcmd`
! If you need inspiration on how to create
more advanced plugins then I recommend you to look at the
[
source
](
kattcmd/commands
)
, because each command that
`kattcmd`
comes
with is essentially a plugin.
This diff is collapsed.
Click to expand it.
Henke
@catears
mentioned in issue
#23 (closed)
·
Mar 16, 2018
mentioned in issue
#23 (closed)
mentioned in issue #23
Toggle commit list
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