-
Notifications
You must be signed in to change notification settings - Fork 598
/
CmdPull.groovy
90 lines (72 loc) · 2.58 KB
/
CmdPull.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
* Copyright 2013-2024, Seqera Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nextflow.cli
import com.beust.jcommander.Parameter
import com.beust.jcommander.Parameters
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import nextflow.exception.AbortOperationException
import nextflow.plugin.Plugins
import nextflow.scm.AssetManager
/**
* CLI sub-command PULL
*
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
*/
@Slf4j
@CompileStatic
@Parameters(commandDescription = "Download or update a project")
class CmdPull extends CmdBase implements HubOptions {
static final public NAME = 'pull'
@Parameter(description = 'project name or repository url to pull', arity = 1)
List<String> args
@Parameter(names='-all', description = 'Update all downloaded projects', arity = 0)
boolean all
@Parameter(names=['-r','-revision'], description = 'Revision of the project to run (either a git branch, tag or commit SHA number)')
String revision
@Parameter(names=['-d','-deep'], description = 'Create a shallow clone of the specified depth')
Integer deep
@Override
final String getName() { NAME }
/* only for testing purpose */
protected File root
@Override
void run() {
if( !all && !args )
throw new AbortOperationException('Missing argument')
def list = all ? AssetManager.list() : args.toList()
if( !list ) {
log.info "(nothing to do)"
return
}
/* only for testing purpose */
if( root ) {
AssetManager.root = root
}
// init plugin system
Plugins.init()
list.each {
log.info "Checking $it ..."
def manager = new AssetManager(it, this)
def result = manager.download(revision,deep)
manager.updateModules()
def scriptFile = manager.getScriptFile()
String message = !result ? " done" : " $result"
message += " - revision: ${scriptFile.revisionInfo}"
log.info message
}
}
}