]>
Commit | Line | Data |
---|---|---|
f67539c2 TL |
1 | (in-package #:cl-user) |
2 | ||
3 | ;;;; Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | ;;;; you may not use this file except in compliance with the License. | |
5 | ;;;; You may obtain a copy of the License at | |
6 | ;;;; | |
7 | ;;;; http://www.apache.org/licenses/LICENSE-2.0 | |
8 | ;;;; | |
9 | ;;;; Unless required by applicable law or agreed to in writing, software | |
10 | ;;;; distributed under the License is distributed on an "AS IS" BASIS, | |
11 | ;;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 | ;;;; See the License for the specific language governing permissions and | |
13 | ;;;; limitations under the License. | |
14 | ||
15 | (require "asdf") | |
16 | (load (merge-pathnames "../../lib/cl/load-locally.lisp" *load-truename*)) | |
17 | (asdf:load-system :net.didierverna.clon) | |
18 | (asdf:load-asd (merge-pathnames "gen-cl/ThriftTest/thrift-gen-ThriftTest.asd" *load-truename*)) | |
19 | (asdf:load-system :thrift-gen-thrifttest) | |
20 | (load (merge-pathnames "implementation.lisp" *load-truename*)) | |
21 | ||
22 | (net.didierverna.clon:nickname-package) | |
23 | ||
24 | (clon:defsynopsis () | |
25 | (text :contents "The Common Lisp server for Thrift's cross-language test suite.") | |
26 | (group (:header "Allowed options:") | |
27 | (flag :short-name "h" :long-name "help" | |
28 | :description "Print this help and exit.") | |
29 | (stropt :long-name "port" | |
30 | :description "Number of the port to listen for connections on." | |
31 | :default-value "9090" | |
32 | :argument-name "ARG" | |
33 | :argument-type :optional) | |
34 | (stropt :long-name "server-type" | |
35 | :description "The type of server, currently only \"simple\" is available." | |
36 | :default-value "simple" | |
37 | :argument-name "ARG") | |
38 | (stropt :long-name "transport" | |
39 | :description "Transport: transport to use (\"buffered\" or \"framed\")" | |
40 | :default-value "buffered" | |
41 | :argument-name "ARG") | |
42 | (stropt :long-name "protocol" | |
43 | :description "Protocol: protocol to use (\"binary\" or \"multi\")" | |
44 | :default-value "binary" | |
45 | :argument-name "ARG"))) | |
46 | ||
47 | (defun main () | |
48 | "Entry point for our standalone application." | |
49 | (clon:make-context) | |
50 | (when (clon:getopt :short-name "h") | |
51 | (clon:help) | |
52 | (clon:exit)) | |
53 | (let ((port "9090") | |
54 | (framed nil) | |
55 | (multiplexed nil)) | |
56 | (clon:do-cmdline-options (option name value source) | |
57 | (print (list option name value source)) | |
58 | (if (string= name "port") | |
59 | (setf port value)) | |
60 | (if (string= name "transport") | |
61 | (cond ((string= value "buffered") (setf framed nil)) | |
62 | ((string= value "framed") (setf framed t)) | |
63 | (t (error "Unsupported transport.")))) | |
64 | (if (string= name "protocol") | |
65 | (cond ((string= value "binary") (setf multiplexed nil)) | |
66 | ((string= value "multi") (setf multiplexed t)) | |
67 | (t (error "Unsupported protocol."))))) | |
68 | (terpri) | |
69 | (let ((services (if multiplexed | |
70 | (list thrift.test:thrift-test thrift.test:second-service) | |
71 | thrift.test:thrift-test))) | |
72 | (thrift:serve (puri:parse-uri (concatenate 'string | |
73 | "thrift://127.0.0.1:" | |
74 | port)) | |
75 | services | |
76 | :framed framed | |
77 | :multiplexed multiplexed))) | |
78 | (clon:exit)) | |
79 | ||
80 | (clon:dump "TestServer" main) |