github.com/joomcode/cue@v0.4.4-0.20221111115225-539fe3512047/cue/testdata/definitions/files.txtar (about)

     1  // Treat fields of different files as belonging to the same struct.
     2  // This means that a closed embedding in one file should not restrict the
     3  // fields of another.
     4  
     5  -- in.cue --
     6  package foo
     7  
     8  #theme: {
     9  	color:   string
    10  	ctermbg: string
    11  }
    12  dark: #theme & {
    13  	color:   "dark"
    14  	ctermbg: "239"
    15  }
    16  light: #theme & {
    17  	color:   "light"
    18  	ctermbg: "254"
    19  }
    20  #Config: {
    21  	console: dark | *light
    22  }
    23  -- box.cue --
    24  package foo
    25  
    26  #Config & {
    27  	console: dark
    28  }
    29  -- out/eval --
    30  (#struct){
    31    #theme: (#struct){
    32      color: (string){ string }
    33      ctermbg: (string){ string }
    34    }
    35    dark: (#struct){
    36      color: (string){ "dark" }
    37      ctermbg: (string){ "239" }
    38    }
    39    light: (#struct){
    40      color: (string){ "light" }
    41      ctermbg: (string){ "254" }
    42    }
    43    #Config: (#struct){
    44      console: (#struct){ |(*(#struct){
    45          color: (string){ "light" }
    46          ctermbg: (string){ "254" }
    47        }, (#struct){
    48          color: (string){ "dark" }
    49          ctermbg: (string){ "239" }
    50        }) }
    51    }
    52    console: (#struct){
    53      color: (string){ "dark" }
    54      ctermbg: (string){ "239" }
    55    }
    56  }
    57  -- out/compile --
    58  --- in.cue
    59  {
    60    #theme: {
    61      color: string
    62      ctermbg: string
    63    }
    64    dark: (〈0;#theme〉 & {
    65      color: "dark"
    66      ctermbg: "239"
    67    })
    68    light: (〈0;#theme〉 & {
    69      color: "light"
    70      ctermbg: "254"
    71    })
    72    #Config: {
    73      console: (〈1;dark〉|*〈1;light〉)
    74    }
    75  }
    76  --- box.cue
    77  {
    78    (〈0;#Config〉 & {
    79      console: 〈1;dark〉
    80    })
    81  }