Subversion Repositories Koakuma

Rev

Rev 11 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

#!/usr/bin/env tclsh
# $Id: create-project.in 12 2024-10-02 03:25:33Z nishi $
package require tdom
foreach path [glob "@@PREFIX@@/lib/koakuma/utility/*.tcl"] {
        source $path
}
foreach arg $argv {
        if { [string range "$arg" 0 0] == "-" } {
                if { "$arg" == "-h" || "$arg" == "--help" } {
                        puts "Usage: $argv0"
                        puts "You can set the environment variable `KOAKUMA_RPC' to override default RPC URL."
                        puts "Default: http://127.0.0.1/koakuma/rpc"
                        exit 0
                }
        }
}

::rpc::init

dom createNodeCmd -tagName "name" -jsonType NONE elementNode keyName
dom createNodeCmd -tagName "description" -jsonType NONE elementNode keyDescription
dom createNodeCmd -tagName "vcs" -jsonType NONE elementNode keyVCS
dom createNodeCmd -tagName "url" -jsonType NONE elementNode keyURL

dom createNodeCmd -jsonType STRING textNode valueString

set doc [dom createDocumentNode]

proc ask_for {show var} {
        upvar 1 $var $var
        puts -nonewline "$show: "
        flush stdout
        set $var "[gets stdin]"
}

ask_for "Name" name
ask_for "Description" description
ask_for "VCS" vcs
puts "Example URL for CVS: pserver://anon:@cvs.nishi.boats/cvs/nishi@tewi"
puts "Example URL for CVS: ssh://anoncvs:anoncvs@cvs.nishi.boats/cvs/nishi@tewi"
ask_for "VCS URL" url

$doc appendFromScript {
        keyName {valueString "$name"}
        keyDescription {valueString "$description"}
        keyVCS {valueString "$vcs"}
        keyURL {valueString "$url"}
}
set result [::rpc::send "/create-project" "[$doc asJSON]"]
if { [lindex $result 0] == 200 } {
} else {
        set doc [dom parse -json "[lindex $result 1]"]
        puts "Error: [$doc selectNodes "string(/error)"]"
}