File: scope-loader.vala

package info (click to toggle)
libunity 7.1.4%2B19.04.20190319-5
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 1,636 kB
  • sloc: makefile: 704; python: 399; ansic: 141; sh: 9; xml: 7
file content (64 lines) | stat: -rw-r--r-- 1,247 bytes parent folder | download | duplicates (3)
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
/* -*- mode: vala; c-basic-offset: 2; indent-tabs-mode: nil -*- */

namespace Options
{
  private static string group;
  private static string module;
}

const OptionEntry[] options =
{
  {
    "group", 'g', 0, OptionArg.STRING, out Options.group,
    "Scope group configuration", null
  },
  {
    "module", 'm', 0, OptionArg.STRING, out Options.module,
    "Scope shared library (for testing)", null
  },
  {
    null
  }
};

public int main (string[] args)
{
  Environment.set_prgname ("unity-scope-loader");
  var opt_context = new OptionContext("[scope-ids]");
  opt_context.add_main_entries (options, null);
  if (args.length <= 1)
  {
    print ("%s\n", opt_context.get_help (true, null));
    return 0;
  }

  var loader = new Unity.ScopeLoader ();
  try
  {
    opt_context.parse (ref args);

    if (Options.group != null)
    {
      loader.load_group (Options.group);
    }
    else if (Options.module != null)
    {
      loader.load_module (Options.module, "C");
    }
    else
    {
      for (var i = 1; i < args.length; i++)
      {
        var scope_id = args[i];
        loader.load_scope (scope_id);
      }
    }
  }
  catch (Error err)
  {
    error ("%s", err.message);
  }

  Unity.ScopeDBusConnector.run ();
  return 0;
}