[cli] add a --version argument
This commit is contained in:
parent
85dc7a6d21
commit
6041af04ca
|
@ -98,6 +98,7 @@ namespace SparkleLib {
|
||||||
private void InstallUserInfo ()
|
private void InstallUserInfo ()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// TODO: Use TargetFolder and move SparklePaths out of SparkleLib
|
||||||
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
|
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
|
||||||
|
|
||||||
if (File.Exists (global_config_file_path)) {
|
if (File.Exists (global_config_file_path)) {
|
||||||
|
|
|
@ -25,13 +25,15 @@ namespace SparkleShare {
|
||||||
// This is SparkleShare!
|
// This is SparkleShare!
|
||||||
public class SparkleShare {
|
public class SparkleShare {
|
||||||
|
|
||||||
|
public static SparkleUI SparkleUI;
|
||||||
|
|
||||||
|
|
||||||
// Short alias for the translations
|
// Short alias for the translations
|
||||||
public static string _ (string s)
|
public static string _ (string s)
|
||||||
{
|
{
|
||||||
return Catalog.GetString (s);
|
return Catalog.GetString (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SparkleUI SparkleUI;
|
|
||||||
|
|
||||||
public static void Main (string [] args)
|
public static void Main (string [] args)
|
||||||
{
|
{
|
||||||
|
@ -60,26 +62,44 @@ namespace SparkleShare {
|
||||||
Environment.Exit (0);
|
Environment.Exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the command line arguments
|
|
||||||
bool HideUI = false;
|
bool HideUI = false;
|
||||||
|
|
||||||
|
// Parse the command line arguments
|
||||||
if (args.Length > 0) {
|
if (args.Length > 0) {
|
||||||
|
|
||||||
foreach (string Argument in args) {
|
foreach (string Argument in args) {
|
||||||
|
|
||||||
if (Argument.Equals ("--disable-gui") || Argument.Equals ("-d"))
|
if (Argument.Equals ("--disable-gui") || Argument.Equals ("-d"))
|
||||||
HideUI = true;
|
HideUI = true;
|
||||||
|
|
||||||
|
if (Argument.Equals ("--version") || Argument.Equals ("-v")) {
|
||||||
|
|
||||||
|
PrintVersion ();
|
||||||
|
Environment.Exit (0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (Argument.Equals ("--help") || Argument.Equals ("-h")) {
|
if (Argument.Equals ("--help") || Argument.Equals ("-h")) {
|
||||||
|
|
||||||
ShowHelp ();
|
ShowHelp ();
|
||||||
Environment.Exit (0);
|
Environment.Exit (0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SparkleUI = new SparkleUI (HideUI);
|
SparkleUI = new SparkleUI (HideUI);
|
||||||
SparkleUI.Run();
|
SparkleUI.Run();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prints the help output
|
// Prints the help output
|
||||||
public static void ShowHelp ()
|
public static void ShowHelp ()
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine (_("SparkleShare Copyright (C) 2010 Hylke Bons"));
|
Console.WriteLine (_("SparkleShare Copyright (C) 2010 Hylke Bons"));
|
||||||
Console.WriteLine (" ");
|
Console.WriteLine (" ");
|
||||||
Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
|
Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
|
||||||
|
@ -93,8 +113,19 @@ namespace SparkleShare {
|
||||||
Console.WriteLine (" ");
|
Console.WriteLine (" ");
|
||||||
Console.WriteLine (_("Arguments:"));
|
Console.WriteLine (_("Arguments:"));
|
||||||
Console.WriteLine (_("\t -d, --disable-gui\tDon't show the notification icon."));
|
Console.WriteLine (_("\t -d, --disable-gui\tDon't show the notification icon."));
|
||||||
Console.WriteLine (_("\t -h, --help\t\tDisplay this help text."));
|
Console.WriteLine (_("\t -h, --help\t\tShow this help text."));
|
||||||
|
Console.WriteLine (_("\t -v, --version\t\tPrint version information."));
|
||||||
Console.WriteLine (" ");
|
Console.WriteLine (" ");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Prints the version information
|
||||||
|
public static void PrintVersion ()
|
||||||
|
{
|
||||||
|
|
||||||
|
Console.WriteLine (_("SparkleShare " + Defines.VERSION));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,7 +256,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Menu.Add (new SeparatorMenuItem ());
|
Menu.Add (new SeparatorMenuItem ());
|
||||||
|
|
||||||
MenuItem about_item = new MenuItem (_("About"));
|
MenuItem about_item = new MenuItem (_("Visit Website"));
|
||||||
|
|
||||||
about_item.Activated += delegate {
|
about_item.Activated += delegate {
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
Timer.Stop ();
|
Timer.Stop ();
|
||||||
|
|
||||||
Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24);
|
Pixbuf = AnimationFrames [0];
|
||||||
StateText = _("Up to date") + " (" + FormatFileSize (FolderSize) + ")";
|
StateText = _("Up to date") + " (" + FormatFileSize (FolderSize) + ")";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace SparkleShare {
|
namespace SparkleShare {
|
||||||
|
|
||||||
|
@ -47,6 +49,8 @@ namespace SparkleShare {
|
||||||
BusG.Init ();
|
BusG.Init ();
|
||||||
Gtk.Application.Init ();
|
Gtk.Application.Init ();
|
||||||
|
|
||||||
|
SetProcessName ("sparkleshare");
|
||||||
|
|
||||||
Repositories = new List <SparkleRepo> ();
|
Repositories = new List <SparkleRepo> ();
|
||||||
|
|
||||||
Process = new Process () {
|
Process = new Process () {
|
||||||
|
@ -106,6 +110,7 @@ namespace SparkleShare {
|
||||||
NotificationIcon = new SparkleStatusIcon ();
|
NotificationIcon = new SparkleStatusIcon ();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -418,6 +423,27 @@ namespace SparkleShare {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[DllImport ("libc")]
|
||||||
|
private static extern int prctl (int option, byte [] arg2, IntPtr arg3, IntPtr arg4, IntPtr arg5);
|
||||||
|
|
||||||
|
|
||||||
|
private void SetProcessName (string name)
|
||||||
|
{
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
if (prctl (15, Encoding.ASCII.GetBytes (name + "\0"), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) != 0) {
|
||||||
|
|
||||||
|
throw new ApplicationException ("Error setting process name: " +
|
||||||
|
Mono.Unix.Native.Stdlib.GetLastError ());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (EntryPointNotFoundException) {}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue