1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*!
Framework for creating a typeshare binary.
This library provides a macro that creates a `fn main` that implements an
entire typeshare binary, using only the [Language](https://docs.rs/typeshare-model/latest/typeshare_model/trait.Language.html)
implementations that you provide.
The macro is very simple. Supposing that you have implementations of `Language`
called `Kotlin` and `Swift`, call the macro like this:
```ignore
use std::marker::PhantomData;
use typeshare_driver::typeshare_binary;
struct Kotlin {}
// impl<'config> Language<'config> for Kotlin { ... }
struct Swift<'c> {
config: PhantomData<&'config str>;
}
// impl<'config> Language<'config> for Swift<'config> { ... }
typeshare_binary! { Kotlin, Swift<'config> }
```
This creates an `fn main` that uses the functionality in [typeshare-engine][typeshare_engine]
to create a complete, working typeshare binary. That binary will include a
complete command-line interface, populated with global options like `--config`
and `--lang`, as well as language-specific options like `--kotlin-package`;
these language-specific flags are determined automatically based on the
[`Config`](https://docs.rs/typeshare-model/latest/typeshare_model/trait.Language.html#associatedtype.Config)
type provided by each `Language` implementation. Use `--help` for a complete
description of all CLI options.
See the [`typeshare_model::Language`](https://docs.rs/typeshare-model/latest/typeshare_model/trait.Language.html)
docs for details on how to create a specific language implementation.
See the [typeshare-engine][typeshare_engine] docs if you want to use typeshare
as a library instead of a binary program; it contains all of the actual logic
for *running* typeshare. typeshare-driver just bootstraps the functionality
in the engine into a working `main`.
*/
/**
Macro that creates an `fn main` with a complete typeshare program, based on
the `Language` implementations provided. See the [crate docs][crate] for
details and an example.
*/
$crate
}
};
}