[cli] add a --version argument

This commit is contained in:
Hylke Bons 2010-08-09 23:54:43 +01:00
parent 85dc7a6d21
commit 6041af04ca
4 changed files with 63 additions and 5 deletions

View file

@ -98,6 +98,7 @@ namespace SparkleLib {
private void InstallUserInfo ()
{
// TODO: Use TargetFolder and move SparklePaths out of SparkleLib
string global_config_file_path = SparkleHelpers.CombineMore (SparklePaths.SparkleConfigPath, "config");
if (File.Exists (global_config_file_path)) {

View file

@ -25,13 +25,15 @@ namespace SparkleShare {
// This is SparkleShare!
public class SparkleShare {
public static SparkleUI SparkleUI;
// Short alias for the translations
public static string _ (string s)
{
return Catalog.GetString (s);
}
public static SparkleUI SparkleUI;
public static void Main (string [] args)
{
@ -60,26 +62,44 @@ namespace SparkleShare {
Environment.Exit (0);
}
// Parse the command line arguments
bool HideUI = false;
// Parse the command line arguments
if (args.Length > 0) {
foreach (string Argument in args) {
if (Argument.Equals ("--disable-gui") || Argument.Equals ("-d"))
HideUI = true;
if (Argument.Equals ("--version") || Argument.Equals ("-v")) {
PrintVersion ();
Environment.Exit (0);
}
if (Argument.Equals ("--help") || Argument.Equals ("-h")) {
ShowHelp ();
Environment.Exit (0);
}
}
}
SparkleUI = new SparkleUI (HideUI);
SparkleUI.Run();
}
// Prints the help output
public static void ShowHelp ()
{
Console.WriteLine (_("SparkleShare Copyright (C) 2010 Hylke Bons"));
Console.WriteLine (" ");
Console.WriteLine (_("This program comes with ABSOLUTELY NO WARRANTY."));
@ -93,8 +113,19 @@ namespace SparkleShare {
Console.WriteLine (" ");
Console.WriteLine (_("Arguments:"));
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 (" ");
}
// Prints the version information
public static void PrintVersion ()
{
Console.WriteLine (_("SparkleShare " + Defines.VERSION));
}
}

View file

@ -256,7 +256,7 @@ namespace SparkleShare {
Menu.Add (new SeparatorMenuItem ());
MenuItem about_item = new MenuItem (_("About"));
MenuItem about_item = new MenuItem (_("Visit Website"));
about_item.Activated += delegate {
@ -331,7 +331,7 @@ namespace SparkleShare {
Timer.Stop ();
Pixbuf = SparkleHelpers.GetIcon ("folder-sparkleshare", 24);
Pixbuf = AnimationFrames [0];
StateText = _("Up to date") + " (" + FormatFileSize (FolderSize) + ")";
}

View file

@ -23,6 +23,8 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace SparkleShare {
@ -47,6 +49,8 @@ namespace SparkleShare {
BusG.Init ();
Gtk.Application.Init ();
SetProcessName ("sparkleshare");
Repositories = new List <SparkleRepo> ();
Process = new Process () {
@ -106,6 +110,7 @@ namespace SparkleShare {
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) {}
}
}
}