pluie-echo/samples/pluie-outputFormatter.vala

64 lines
1.8 KiB
Vala
Raw Permalink Normal View History

2017-11-04 02:14:21 +00:00
using GLib;
using Pluie;
errordomain MyError {
CODE
}
int main (string[] args)
{
Echo.init (true, "echo.ini");
2017-11-04 02:14:21 +00:00
Dbg.in (Log.METHOD, null, Log.LINE, Log.FILE);
of.title ("MyApp", "0.2.2", "a-sansara");
2017-11-04 02:14:21 +00:00
of.echo ("sample echo\n");
2017-11-04 02:14:21 +00:00
of.keyval ("path", "/tmp/blob");
of.keyval ("otherlongoption", "other value");
2017-11-04 02:14:21 +00:00
of.echo ("\nsample echo\non multiple\nline", true, true);
2017-11-04 02:14:21 +00:00
of.action ("reading config", "toto.conf");
2017-11-04 02:14:21 +00:00
of.state (false);
2017-11-04 02:14:21 +00:00
of.warn ("boloss warning");
of.echo ();
var cmd = new Sys.Cmd ("ls -la");
int status = cmd.run();
2017-11-04 02:14:21 +00:00
of.action ("running cmd", cmd.name);
of.echo ("\n%s".printf (cmd.output), true, true);
2017-11-04 02:14:21 +00:00
of.state (status == 0);
2017-11-04 02:14:21 +00:00
try {
throw new MyError.CODE("this is the error message");
}
catch (MyError e) {
of.error (e.message);
}
of.rs (true);
of.rs (true, "ok");
of.rs (false, "", "exit");
2017-11-04 02:14:21 +00:00
of.echo();
2017-11-04 02:14:21 +00:00
string com = "Vala is syntactically similar to C# and includes several features such as: anonymous functions, signals, properties, generics, assisted memory management, exception handling, type inference, and foreach statements.[3] Its developers Jürg Billeter and Raffaele Sandrini aim to bring these features to the plain C runtime with little overhead and no special runtime support by targeting the GObject object system";
string mycom = of.wordwrap (com, of.term_width-44);
int line = mycom.split("\n").length;
of.echo (mycom, true, true, ECHO.COMMENT, 40);
2017-11-04 02:14:21 +00:00
of.usage_option ("quiet", "q", "SHUTUP", false, line);
of.echo();
2017-11-04 02:14:21 +00:00
of.echo (mycom, true, true, ECHO.COMMENT, 40);
of.usage_option ("record-desktop", "r", "TIME", false, line);
of.echo();
Dbg.out (Log.METHOD, null, Log.LINE, Log.FILE);
return 0;
}