Subversion Repositories Koakuma

Rev

Rev 8 | Rev 12 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 nishi 1
#!/usr/bin/env tclsh
2
# $Id: create-project.in 11 2024-10-02 00:56:50Z nishi $
5 nishi 3
package require tdom
4 nishi 4
foreach arg $argv {
5
	if { [string range "$arg" 0 0] == "-" } {
6
		if { "$arg" == "-h" || "$arg" == "--help" } {
7
			puts "Usage: create-project"
8
			puts "You can set the environment variable `KOAKUMA_RPC' to override default RPC URL."
9
			puts "Default: $RPC_URL"	
10
			exit 0
11
		}
12
	}
13
}
14
foreach path [glob "@@PREFIX@@/lib/koakuma/utility/*.tcl"] {
15
	source $path
16
}
5 nishi 17
 
11 nishi 18
::rpc::init
19
 
5 nishi 20
dom createNodeCmd -tagName "name" -jsonType NONE elementNode keyName
21
dom createNodeCmd -tagName "description" -jsonType NONE elementNode keyDescription
22
dom createNodeCmd -tagName "vcs" -jsonType NONE elementNode keyVCS
23
dom createNodeCmd -tagName "url" -jsonType NONE elementNode keyURL
24
 
25
dom createNodeCmd -jsonType STRING textNode valueString
26
 
27
set doc [dom createDocumentNode]
28
 
29
proc ask_for {show var} {
30
	upvar 1 $var $var
31
	puts -nonewline "$show: "
32
	flush stdout
33
	set $var "[gets stdin]"
34
}
35
 
36
ask_for "Name" name
37
ask_for "Description" description
38
ask_for "VCS" vcs
11 nishi 39
puts "Example URL for CVS: pserver://anon:@cvs.nishi.boats/cvs/nishi@tewi"
40
puts "Example URL for CVS: ssh://anoncvs:anoncvs@cvs.nishi.boats/cvs/nishi@tewi"
5 nishi 41
ask_for "VCS URL" url
42
 
43
$doc appendFromScript {
44
	keyName {valueString "$name"}
45
	keyDescription {valueString "$description"}
46
	keyVCS {valueString "$vcs"}
47
	keyURL {valueString "$url"}
48
}
49
set result [::rpc::send "/create-project" "[$doc asJSON]"]
50
if { [lindex $result 0] == 200 } {
51
} else {
52
	set doc [dom parse -json "[lindex $result 1]"]
53
	puts "Error: [$doc selectNodes "string(/error)"]"
54
}