#!/usr/bin/env dub
/+ dub.sdl:
name "dub"
dependency "sparkles:core-cli" path="../../../../.."
targetPath "build"
// Optimised, assertions live, `debug {}` blocks out — the build every nix
// artifact uses. Neither `debug` (which compiles those blocks in) nor
// `release` (which deletes assert *expressions*, side effects included).
buildType "checked" {
buildOptions "optimize" "inline" "debugInfo"
}
+/
// ci: run --help
import (package) sparklessparkles.(package) sparkles.core_clicore_cli.(module) sparkles.core_cli.argsargs;
import (package) sparklessparkles.(package) sparkles.basebase.(module) sparkles.base.prettyprintprettyprint : (alias template) dub.prettyPrint = sparkles.base.prettyprint.prettyPrint(T, Hook = void)(in T value, in PrettyPrintOptions!Hook opt = PrettyPrintOptions!Hook())Convenience overload that returns a string.
prettyPrint;
import (package) sparklessparkles.(package) sparkles.basebase.(module) sparkles.base.styled_templateStyle template processing for IES (Interpolated Expression Sequences).
Provides a template syntax for applying terminal styles to IES strings:
import sparkles.base.styled_template;
int cpu = 75;
styledWriteln(i"CPU: {red $(cpu)%} Status: {green OK}");
Supported syntax:
{red text} — Apply single style
{bold.red text} — Chain multiple styles
{bold outer {red nested}} — Nested blocks (inner inherits outer)
{red text {~red normal}} — Negation with ~ removes a style
#{ — Escaped literal {
#} — Escaped literal }
styled_template : (alias template) dub.styledWriteln = sparkles.base.styled_template.styledWriteln(Args...)(ColorDepth depth, InterpolationHeader header, Args args, InterpolationFooter footer)Write styled IES to stdout with newline.
styledWriteln;
import (package) stdstd.(module) std.sumtypeSumType is a generic discriminated union implementation that uses
design-by-introspection to generate safe and efficient code. Its features
include:
Pattern matching.
Support for self-referential types.
Full attribute correctness (pure, @safe, @nogc, and nothrow are
inferred whenever possible).
A type-safe and memory-safe API compatible with DIP 1000 (scope).
No dependency on runtime type information (TypeInfo).
Compatibility with BetterC.
List of examples
Memory corruption (why assignment can be @system)
Source
std/sumtype.d
Examples
Basic usage
import std.math.operations : isClose;
struct Fahrenheit { double value; }
struct Celsius { double value; }
struct Kelvin { double value; }
alias Temperature = SumType!(Fahrenheit, Celsius, Kelvin);
// Construct from any of the member types.
Temperature t1 = Fahrenheit(98.6);
Temperature t2 = Celsius(100);
Temperature t3 = Kelvin(273);
// Use pattern matching to access the value.
Fahrenheit toFahrenheit(Temperature t)
{
return Fahrenheit(
t.match!(
(Fahrenheit f) => f.value,
(Celsius c) => c.value * 9.0/5 + 32,
(Kelvin k) => k.value * 9.0/5 - 459.4
)
);
}
assert(toFahrenheit(t1).value.isClose(98.6));
assert(toFahrenheit(t2).value.isClose(212));
assert(toFahrenheit(t3).value.isClose(32));
// Use ref to modify the value in place.
void freeze(ref Temperature t)
{
t.match!(
(ref Fahrenheit f) => f.value = 32,
(ref Celsius c) => c.value = 0,
(ref Kelvin k) => k.value = 273
);
}
freeze(t1);
assert(toFahrenheit(t1).value.isClose(32));
// Use a catch-all handler to give a default result.
bool isFahrenheit(Temperature t)
{
return t.match!(
(Fahrenheit f) => true,
_ => false
);
}
assert(isFahrenheit(t1));
assert(!isFahrenheit(t2));
assert(!isFahrenheit(t3));
Matching with an overload set
Instead of writing match handlers inline as lambdas, you can write them as
overloads of a function. An alias can be used to create an additional
overload for the SumType itself.
For example, with this overload set:
string handle(int n) { return "got an int"; }
string handle(string s) { return "got a string"; }
string handle(double d) { return "got a double"; }
alias handle = match!handle;
Usage would look like this:
alias ExampleSumType = SumType!(int, string, double);
ExampleSumType a = 123;
ExampleSumType b = "hello";
ExampleSumType c = 3.14;
assert(a.handle == "got an int");
assert(b.handle == "got a string");
assert(c.handle == "got a double");
Recursive SumTypes
This example makes use of the special placeholder type This to define a
recursive data type: an
abstract syntax tree for
representing simple arithmetic expressions.
import std.functional : partial;
import std.traits : EnumMembers;
import std.typecons : Tuple;
enum Op : string
{
Plus = "+",
Minus = "-",
Times = "*",
Div = "/"
}
// An expression is either
// - a number,
// - a variable, or
// - a binary operation combining two sub-expressions.
alias Expr = SumType!(
double,
string,
Tuple!(Op, "op", This*, "lhs", This*, "rhs")
);
// Shorthand for Tuple!(Op, "op", Expr*, "lhs", Expr*, "rhs"),
// the Tuple type above with Expr substituted for This.
alias BinOp = Expr.Types[2];
// Factory function for number expressions
Expr* num(double value)
{
return new Expr(value);
}
// Factory function for variable expressions
Expr* var(string name)
{
return new Expr(name);
}
// Factory function for binary operation expressions
Expr* binOp(Op op, Expr* lhs, Expr* rhs)
{
return new Expr(BinOp(op, lhs, rhs));
}
// Convenience wrappers for creating BinOp expressions
alias sum = partial!(binOp, Op.Plus);
alias diff = partial!(binOp, Op.Minus);
alias prod = partial!(binOp, Op.Times);
alias quot = partial!(binOp, Op.Div);
// Evaluate expr, looking up variables in env
double eval(Expr expr, double[string] env)
{
return expr.match!(
(double num) => num,
(string var) => env[var],
(BinOp bop)
{
double lhs = eval(*bop.lhs, env);
double rhs = eval(*bop.rhs, env);
final switch (bop.op)
{
static foreach (op; EnumMembers!Op)
{
case op:
return mixin("lhs" ~ op ~ "rhs");
}
}
}
);
}
// Return a "pretty-printed" representation of expr
string pprint(Expr expr)
{
import std.format : format;
return expr.match!(
(double num) => "%g".format(num),
(string var) => var,
(BinOp bop) => "(%s %s %s)".format(
pprint(*bop.lhs),
cast(string) bop.op,
pprint(*bop.rhs)
)
);
}
Expr* myExpr = sum(var("a"), prod(num(2), var("b")));
double[string] myEnv = ["a":3, "b":4, "c":7];
assert(eval(*myExpr, myEnv) == 11);
assert(pprint(*myExpr) == "(a + (2 * b))");
sumtype;
@((struct) sparkles.core_cli.args.uda.CommandCommand("build",
aliases: ["b"],
shortDescription: "Builds a package (uses the main package in the current working directory by default)",
helpSections: ["description"],
))
struct (struct) dub.BuildBuild
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`b|build`, allowedValues: [
"debug", "plain", "release", "release-debug", "release-nobounds",
"unittest", "profile", "profile-gc", "docs", "ddox",
"cov", "unittest-cov", "syntax",
]))
(alias) object.string = stringstring (field) string dub.Build.buildTypebuildType = "debug";
@((struct) sparkles.core_cli.args.uda.OptionOption(`compiler`, allowedValues: ["dmd", "ldc", "ldc2", "gdc"]))
(alias) object.string = stringstring (field) string dub.Build.compilercompiler;
@((struct) sparkles.core_cli.args.uda.OptionOption(`a|arch`))
(alias) object.string = stringstring (field) string dub.Build.archarch;
@((struct) sparkles.core_cli.args.uda.OptionOption(`c|config`))
(alias) object.string = stringstring[] (field) string[] dub.Build.configsconfigs;
@((struct) sparkles.core_cli.args.uda.OptionOption(`f|force`))
bool (field) bool dub.Build.forceforce;
@((struct) sparkles.core_cli.args.uda.OptionOption("combined", description: "Tries to build the whole project in a single compiler run"))
bool (field) bool dub.Build.combinedcombined;
@((struct) sparkles.core_cli.args.uda.OptionOption("rdmd", description: "Use rdmd instead of directly invoking the compiler"))
bool (field) bool dub.Build.rdmdrdmd;
@((struct) sparkles.core_cli.args.uda.OptionOption(`build-mode`, allowedValues: ["separate", "allAtOnce", "singleFile"]))
(alias) object.string = stringstring (field) string dub.Build.buildModebuildMode = "separate";
@((struct) sparkles.core_cli.args.uda.OptionOption("temp-build", description: "Builds the project in the temp folder if possible"))
bool (field) bool dub.Build.tempBuildtempBuild;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package", optional: true))
(alias) object.string = stringstring (field) string dub.Build.packageNamepackageName;
void void dub.Build.run!(sparkles.core_cli.args.internal.CommandNode!(Dub))(in sparkles.core_cli.args.internal.CommandNode!(Dub) program) @systemrun(Program)(in (alias) Program = sparkles.core_cli.args.internal.CommandNode!(Dub)Program (parameter) const(sparkles.core_cli.args.internal.CommandNode!(Dub)) programprogram) =>
void sparkles.base.styled_template.styledWriteln!(core.interpolation.InterpolatedLiteral!"Running {bold dub build} with params:\n globals: --verbose=", core.interpolation.InterpolatedExpression!"program.value.verbose", const(uint), core.interpolation.InterpolatedLiteral!", --quiet=", core.interpolation.InterpolatedExpression!"program.value.quiet", const(bool), core.interpolation.InterpolatedLiteral!", --color='", core.interpolation.InterpolatedExpression!"program.value.color", string, core.interpolation.InterpolatedLiteral!"'\n params: ", core.interpolation.InterpolatedExpression!"prettyPrint(this)", string)(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Running {bold dub build} with params:\n globals: --verbose=" __param_1, core.interpolation.InterpolatedExpression!"program.value.verbose" __param_2, const(uint) __param_3, core.interpolation.InterpolatedLiteral!", --quiet=" __param_4, core.interpolation.InterpolatedExpression!"program.value.quiet" __param_5, const(bool) __param_6, core.interpolation.InterpolatedLiteral!", --color='" __param_7, core.interpolation.InterpolatedExpression!"program.value.color" __param_8, string __param_9, core.interpolation.InterpolatedLiteral!"'\n params: " __param_10, core.interpolation.InterpolatedExpression!"prettyPrint(this)" __param_11, string __param_12, core.interpolation.InterpolationFooter footer) @systemditto — defaults to ColorDepth.trueColor.
styledWriteln(i"Running {bold dub build} with params:
globals: --verbose=$(program.value.verbose), --quiet=$(program.value.quiet), --color='$(program.value.color)'
params: $(prettyPrint(this))");
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("run",
aliases: ["r"],
shortDescription: "Builds and runs a package",
helpSections: ["description"],
))
struct (struct) dub.RunRun
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`b|build`, allowedValues: [
"debug", "plain", "release", "release-debug", "release-nobounds",
"unittest", "profile", "profile-gc", "cov",
]))
(alias) object.string = stringstring (field) string dub.Run.buildTypebuildType = "debug";
@((struct) sparkles.core_cli.args.uda.OptionOption(`compiler`, allowedValues: ["dmd", "ldc", "ldc2", "gdc"]))
(alias) object.string = stringstring (field) string dub.Run.compilercompiler;
@((struct) sparkles.core_cli.args.uda.OptionOption(`c|config`))
(alias) object.string = stringstring[] (field) string[] dub.Run.configsconfigs;
@((struct) sparkles.core_cli.args.uda.OptionOption(`f|force`))
bool (field) bool dub.Run.forceforce;
@((struct) sparkles.core_cli.args.uda.OptionOption("temp-build", description: "Builds in temp directory and runs from there"))
bool (field) bool dub.Run.tempBuildtempBuild;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package", optional: true))
(alias) object.string = stringstring (field) string dub.Run.packageNamepackageName;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("program-args", optional: true))
(alias) object.string = stringstring[] (field) string[] dub.Run.programArgsprogramArgs;
void void dub.Run.run!(sparkles.core_cli.args.internal.CommandNode!(Dub))(in sparkles.core_cli.args.internal.CommandNode!(Dub) program) @systemrun(Program)(in (alias) Program = sparkles.core_cli.args.internal.CommandNode!(Dub)Program (parameter) const(sparkles.core_cli.args.internal.CommandNode!(Dub)) programprogram) =>
void sparkles.base.styled_template.styledWriteln!(core.interpolation.InterpolatedLiteral!"Running {bold dub run} with params:\n globals: --verbose=", core.interpolation.InterpolatedExpression!"program.value.verbose", const(uint), core.interpolation.InterpolatedLiteral!", --quiet=", core.interpolation.InterpolatedExpression!"program.value.quiet", const(bool), core.interpolation.InterpolatedLiteral!", --color='", core.interpolation.InterpolatedExpression!"program.value.color", string, core.interpolation.InterpolatedLiteral!"'\n params: ", core.interpolation.InterpolatedExpression!"prettyPrint(this)", string)(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Running {bold dub run} with params:\n globals: --verbose=" __param_1, core.interpolation.InterpolatedExpression!"program.value.verbose" __param_2, const(uint) __param_3, core.interpolation.InterpolatedLiteral!", --quiet=" __param_4, core.interpolation.InterpolatedExpression!"program.value.quiet" __param_5, const(bool) __param_6, core.interpolation.InterpolatedLiteral!", --color='" __param_7, core.interpolation.InterpolatedExpression!"program.value.color" __param_8, string __param_9, core.interpolation.InterpolatedLiteral!"'\n params: " __param_10, core.interpolation.InterpolatedExpression!"prettyPrint(this)" __param_11, string __param_12, core.interpolation.InterpolationFooter footer) @systemditto — defaults to ColorDepth.trueColor.
styledWriteln(i"Running {bold dub run} with params:
globals: --verbose=$(program.value.verbose), --quiet=$(program.value.quiet), --color='$(program.value.color)'
params: $(prettyPrint(this))");
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("test",
aliases: ["t"],
shortDescription: "Executes the tests of the selected package",
helpSections: ["description"],
))
struct (struct) dub.TestTest
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`b|build`, allowedValues: [
"unittest", "unittest-cov", "unittest-cov-ctfe", "debug",
]))
(alias) object.string = stringstring (field) string dub.Test.buildTypebuildType = "unittest";
@((struct) sparkles.core_cli.args.uda.OptionOption(`compiler`, allowedValues: ["dmd", "ldc", "ldc2", "gdc"]))
(alias) object.string = stringstring (field) string dub.Test.compilercompiler;
@((struct) sparkles.core_cli.args.uda.OptionOption(`c|config`))
(alias) object.string = stringstring[] (field) string[] dub.Test.configsconfigs;
@((struct) sparkles.core_cli.args.uda.OptionOption(`f|force`))
bool (field) bool dub.Test.forceforce;
@((struct) sparkles.core_cli.args.uda.OptionOption("combined", description: "Tries to build the whole project in a single compiler run"))
bool (field) bool dub.Test.combinedcombined;
@((struct) sparkles.core_cli.args.uda.OptionOption("parallel", description: "Runs multiple compiler instances in parallel, if possible"))
bool (field) bool dub.Test.parallel_parallel_;
@((struct) sparkles.core_cli.args.uda.OptionOption("test", description: "Execute the built test binary after compilation. Pass --no-test to compile without running, e.g. for cross-compilation pipelines."))
bool (field) bool dub.Test.test_test_ = true;
@((struct) sparkles.core_cli.args.uda.OptionOption("coverage", description: "Enables code coverage statistics to be generated"))
bool (field) bool dub.Test.coveragecoverage;
@((struct) sparkles.core_cli.args.uda.OptionOption("coverage-ctfe", description: "Enables code coverage (including CTFE) statistics to be generated"))
bool (field) bool dub.Test.coverageCtfecoverageCtfe;
@((struct) sparkles.core_cli.args.uda.OptionOption("main-file", description: "Specifies a custom file containing the main() function to use for running the tests"))
(alias) object.string = stringstring (field) string dub.Test.mainFilemainFile;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package", optional: true))
(alias) object.string = stringstring (field) string dub.Test.packageNamepackageName;
void void dub.Test.run!(sparkles.core_cli.args.internal.CommandNode!(Dub))(in sparkles.core_cli.args.internal.CommandNode!(Dub) program) @systemrun(Program)(in (alias) Program = sparkles.core_cli.args.internal.CommandNode!(Dub)Program (parameter) const(sparkles.core_cli.args.internal.CommandNode!(Dub)) programprogram) =>
void sparkles.base.styled_template.styledWriteln!(core.interpolation.InterpolatedLiteral!"Running {bold dub test} with params:\n globals: --verbose=", core.interpolation.InterpolatedExpression!"program.value.verbose", const(uint), core.interpolation.InterpolatedLiteral!", --quiet=", core.interpolation.InterpolatedExpression!"program.value.quiet", const(bool), core.interpolation.InterpolatedLiteral!", --color='", core.interpolation.InterpolatedExpression!"program.value.color", string, core.interpolation.InterpolatedLiteral!"'\n params: ", core.interpolation.InterpolatedExpression!"prettyPrint(this)", string)(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Running {bold dub test} with params:\n globals: --verbose=" __param_1, core.interpolation.InterpolatedExpression!"program.value.verbose" __param_2, const(uint) __param_3, core.interpolation.InterpolatedLiteral!", --quiet=" __param_4, core.interpolation.InterpolatedExpression!"program.value.quiet" __param_5, const(bool) __param_6, core.interpolation.InterpolatedLiteral!", --color='" __param_7, core.interpolation.InterpolatedExpression!"program.value.color" __param_8, string __param_9, core.interpolation.InterpolatedLiteral!"'\n params: " __param_10, core.interpolation.InterpolatedExpression!"prettyPrint(this)" __param_11, string __param_12, core.interpolation.InterpolationFooter footer) @systemditto — defaults to ColorDepth.trueColor.
styledWriteln(i"Running {bold dub test} with params:
globals: --verbose=$(program.value.verbose), --quiet=$(program.value.quiet), --color='$(program.value.color)'
params: $(prettyPrint(this))");
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("clean",
shortDescription: "Removes intermediate build files and cached build results",
helpSections: ["description"],
))
struct (struct) dub.CleanClean
{
@((struct) sparkles.core_cli.args.uda.OptionOption("all-packages", description: "Cleans all known packages, regardless of whether they are used by the current package or not"))
bool (field) bool dub.Clean.allPackagesallPackages;
@((struct) sparkles.core_cli.args.uda.OptionOption(`root`))
(alias) object.string = stringstring (field) string dub.Clean.rootPathrootPath;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package", optional: true))
(alias) object.string = stringstring (field) string dub.Clean.packageNamepackageName;
void void dub.Clean.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub clean with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Clean, void)(in dub.Clean value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("init",
shortDescription: "Initializes an empty package skeleton",
helpSections: ["description"],
))
struct (struct) dub.InitInit
{
@((struct) sparkles.core_cli.args.uda.OptionOption(
`t|type`,
required: true,
allowedValues: ["minimal", "vibe.d", "deimos", "custom"],
))
(alias) object.string = stringstring (field) string dub.Init.typetype;
@((struct) sparkles.core_cli.args.uda.OptionOption(`f|format`, allowedValues: ["json", "sdl"]))
(alias) object.string = stringstring (field) string dub.Init.formatformat = "json";
@((struct) sparkles.core_cli.args.uda.OptionOption(`n|non-interactive`))
bool (field) bool dub.Init.nonInteractivenonInteractive;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("directory", optional: true))
(alias) object.string = stringstring (field) string dub.Init.directorydirectory;
void void dub.Init.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub init with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Init, void)(in dub.Init value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("fetch",
shortDescription: "Explicitly retrieves and caches packages",
helpSections: ["description"],
))
struct (struct) dub.FetchFetch
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`r|recursive`, description: "Also fetches dependencies of specified packages"))
bool (field) bool dub.Fetch.recursiverecursive;
@((struct) sparkles.core_cli.args.uda.OptionOption(`cache`, allowedValues: ["local", "user", "system"]))
(alias) object.string = stringstring (field) string dub.Fetch.cachecache = "user";
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package"))
(alias) object.string = stringstring (field) string dub.Fetch.packageNamepackageName;
void void dub.Fetch.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub fetch with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Fetch, void)(in dub.Fetch value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("add",
shortDescription: "Adds dependencies to the package file",
helpSections: ["description"],
))
struct (struct) dub.AddAdd
{
@((struct) sparkles.core_cli.args.uda.OptionOption("recipe", description: "Override path to recipe file (dub.sdl/dub.json)"))
(alias) object.string = stringstring (field) string dub.Add.reciperecipe;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("packages"))
(alias) object.string = stringstring[] (field) string[] dub.Add.packagespackages;
void void dub.Add.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub add with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Add, void)(in dub.Add value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("remove",
aliases: ["uninstall"],
shortDescription: "Removes a cached package",
helpSections: ["description"],
))
struct (struct) dub.RemoveRemove
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`n|non-interactive`, description: "Don't enter interactive mode"))
bool (field) bool dub.Remove.nonInteractivenonInteractive;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package"))
(alias) object.string = stringstring (field) string dub.Remove.packageNamepackageName;
void void dub.Remove.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub remove with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Remove, void)(in dub.Remove value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("upgrade",
shortDescription: "Forces an upgrade of the dependencies",
helpSections: ["description"],
))
struct (struct) dub.UpgradeUpgrade
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`prerelease`, description: "Uses the latest pre-release version, even if release versions are available"))
bool (field) bool dub.Upgrade.prereleaseprerelease;
@((struct) sparkles.core_cli.args.uda.OptionOption(`s|sub-packages`, description: "Also upgrades dependencies of all directory based sub packages"))
bool (field) bool dub.Upgrade.subPackagessubPackages;
@((struct) sparkles.core_cli.args.uda.OptionOption(`verify`, description: "Updates the project and performs a build; if successful, rewrites the selected versions file"))
bool (field) bool dub.Upgrade.verifyverify;
@((struct) sparkles.core_cli.args.uda.OptionOption(`dry-run`, description: "Only print what would be upgraded, but don't actually upgrade anything"))
bool (field) bool dub.Upgrade.dryRundryRun;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("packages", optional: true))
(alias) object.string = stringstring[] (field) string[] dub.Upgrade.packagespackages;
void void dub.Upgrade.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub upgrade with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Upgrade, void)(in dub.Upgrade value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("describe",
shortDescription: "Prints a JSON description of the project and its dependencies",
helpSections: ["description"],
))
struct (struct) dub.DescribeDescribe
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`data`))
(alias) object.string = stringstring[] (field) string[] dub.Describe.datadata;
@((struct) sparkles.core_cli.args.uda.OptionOption("data-list", description: "Output --data information separated by newlines instead of spaces"))
bool (field) bool dub.Describe.dataListdataList;
@((struct) sparkles.core_cli.args.uda.OptionOption(`compiler`, allowedValues: ["dmd", "ldc", "ldc2", "gdc"]))
(alias) object.string = stringstring (field) string dub.Describe.compilercompiler;
@((struct) sparkles.core_cli.args.uda.OptionOption(`c|config`))
(alias) object.string = stringstring (field) string dub.Describe.configconfig;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package", optional: true))
(alias) object.string = stringstring (field) string dub.Describe.packageNamepackageName;
void void dub.Describe.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub describe with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Describe, void)(in dub.Describe value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("lint",
shortDescription: "Executes the linter tests of the selected package",
helpSections: ["description"],
))
struct (struct) dub.LintLint
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`syntax-check`))
bool (field) bool dub.Lint.syntaxChecksyntaxCheck;
@((struct) sparkles.core_cli.args.uda.OptionOption(`style-check`))
bool (field) bool dub.Lint.styleCheckstyleCheck;
@((struct) sparkles.core_cli.args.uda.OptionOption(`report-format`, allowedValues: ["default", "checkstyle", "github"]))
(alias) object.string = stringstring (field) string dub.Lint.reportFormatreportFormat = "default";
@((struct) sparkles.core_cli.args.uda.OptionOption(`report-file`))
(alias) object.string = stringstring (field) string dub.Lint.reportFilereportFile;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("package", optional: true))
(alias) object.string = stringstring (field) string dub.Lint.packageNamepackageName;
void void dub.Lint.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub lint with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Lint, void)(in dub.Lint value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("search",
shortDescription: "Search for available packages",
helpSections: ["description"],
))
struct (struct) dub.SearchSearch
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`skip-registry`, allowedValues: ["none", "standard", "configured", "all"]))
(alias) object.string = stringstring (field) string dub.Search.skipRegistryskipRegistry = "none";
@((struct) sparkles.core_cli.args.uda.OptionOption(`registry`))
(alias) object.string = stringstring (field) string dub.Search.registryregistry;
@((struct) sparkles.core_cli.args.uda.ArgumentArgument("query"))
(alias) object.string = stringstring (field) string dub.Search.queryquery;
void void dub.Search.run()run()
{
import (package) stdstd.(module) std.stdioCategory Symbols File handles _popen File isFileHandle openNetwork stderr stdin stdout Reading chunks lines readf readfln readln Writing toFile write writef writefln writeln Misc KeepTerminator LockType StdioException
Standard I/O functions that extend core.stdc.stdio. core.stdc.stdio
is publically imported when importing std.stdio.
There are three layers of I/O:
The lowest layer is the operating system layer. The two main schemes are Windows and Posix.
C's stdio.h which unifies the two operating system schemes.
std.stdio, this module, unifies the various stdio.h implementations into
a high level package for D programs.
Source
std/stdio.d
stdio : (alias template) writeln = std.stdio.writeln(T...)(T args)Equivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Params:
args = the items to write to stdout
Throws:
In case of an I/O error, throws an $(LREF StdioException).
Example:
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
---
writeln;
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln("Running dub search with params:");
void std.stdio.writeln!string(string __param_0) @safeEquivalent to write(args, '\n'). Calling writeln without
arguments is valid and just prints a newline to the standard
output.
Example
Reads stdin and writes it to stdout with an argument
counter.
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
writeln("Input ", count, ": ", line);
}
}
writeln(string sparkles.base.prettyprint.prettyPrint!(dub.Search, void)(in dub.Search value, in sparkles.base.prettyprint.PrettyPrintOptions!void opt = PrettyPrintOptions(cast(ushort)2u, cast(ushort)8u, 32u, 80u, true, false)) pure nothrow @safeConvenience overload that returns a string.
prettyPrint(this));
}
}
@((struct) sparkles.core_cli.args.uda.CommandCommand("dub",
shortDescription: "Package manager and build tool for the D programming language",
helpSections: ["description", "examples"],
))
struct (struct) dub.DubDub
{
@((struct) sparkles.core_cli.args.uda.OptionOption(`v|verbose`, counter: true))
uint (field) uint dub.Dub.verboseverbose;
@((struct) sparkles.core_cli.args.uda.OptionOption(`q|quiet`))
bool (field) bool dub.Dub.quietquiet;
@((struct) sparkles.core_cli.args.uda.OptionOption(`vquiet`))
bool (field) bool dub.Dub.vquietvquiet;
@((struct) sparkles.core_cli.args.uda.OptionOption(`color`, allowedValues: ["auto", "always", "never"]))
(alias) object.string = stringstring (field) string dub.Dub.colorcolor = "auto";
@(struct) sparkles.core_cli.args.uda.SubcommandsSubcommands
SumType!(
(struct) dub.AddAdd,
(struct) dub.BuildBuild,
(struct) dub.CleanClean,
(struct) dub.DescribeDescribe,
(struct) dub.FetchFetch,
(struct) dub.InitInit,
(struct) dub.LintLint,
(struct) dub.RemoveRemove,
(struct) dub.RunRun,
(struct) dub.SearchSearch,
(struct) dub.TestTest,
(struct) dub.UpgradeUpgrade,
) (field) std.sumtype.SumType!(Add, Build, Clean, Describe, Fetch, Init, Lint, Remove, Run, Search, Test, Upgrade) dub.Dub.commandcommand;
}
int int D main(string[] args)main((alias) object.string = stringstring[] (parameter) string[] argsargs)
{
return int sparkles.core_cli.args.internal.runCli!(dub.Dub)(string[] argv) @systemrunCli!(struct) dub.DubDub((parameter) string[] argsargs);
}