blob: 6c0ea21c880106b515026c72acf6cde52141f4b8 [file] [log] [blame]
Marcel van Lohuizen42ebafe2019-04-27 01:24:54 +02001// Copyright 2019 CUE Authors
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// +build ignore
16
17package main
18
19// TODO: remove when we have a cuedoc server. Until then,
20// piggyback on godoc.org.
21
22import (
23 "bytes"
24 "fmt"
25 "io/ioutil"
26 "os"
27)
28
29const msg = `// Code generated by cue get go. DO NOT EDIT.
30
31// Package tool defines statefull operation types for cue commands.
32//
33// This package is only visible in cue files with a _tool.cue or _tool_test.cue
34// ending.
35//
36// CUE configuration files are not influenced by and do not influence anything
37// outside the configuration itself: they are hermetic. Tools solve
38// two problems: allow outside values such as environment variables,
39// file or web contents, random generators etc. to influence configuration,
40// and allow configuration to be actionable from within the tooling itself.
41// Separating these concerns makes it clear to user when outside influences are
42// in play and the tool definition can be strict about what is allowed.
43//
44// Tools are defined in files ending with _tool.cue. These files have a
45// top-level map, "command", which defines all the tools made available through
46// the cue command.
47//
48// The following definitions are for defining commands in tool files:
49// %s
50package tool
51`
52
53func main() {
54 f, _ := os.Create("doc.go")
55 defer f.Close()
56 b, _ := ioutil.ReadFile("tool.cue")
57 i := bytes.Index(b, []byte("package tool"))
58 b = b[i+len("package tool")+1:]
59 b = bytes.ReplaceAll(b, []byte("\n"), []byte("\n// "))
60 fmt.Fprintf(f, msg, string(b))
61}