added SibaCLI

This commit is contained in:
Didier Clermonté 2016-05-03 17:36:45 +02:00
parent cf30fed8bb
commit 8b208a14e0
8 changed files with 104 additions and 23 deletions

Binary file not shown.

View File

@ -1,3 +1,3 @@
#!/bin/sh
java -jar Siba.jar $1 $2
java -jar Siba.jar $1 $2 $3 $4

View File

@ -19,13 +19,17 @@
*/
package org.dclermonte.siba;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.compress.archivers.ArchiveException;
import org.dclermonte.siba.cli.SibaCLI;
import org.dclermonte.siba.gui.SibaGUI;
public class Siba
{
public static void main(final String[] args)
public static void main(final String[] args) throws ArchiveException, IOException, NoSuchAlgorithmException
{
if (args.length == 0)

View File

@ -19,42 +19,114 @@
*/
package org.dclermonte.siba.cli;
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.ResourceBundle;
import org.apache.commons.compress.archivers.ArchiveException;
import org.dclermonte.siba.gui.SibaGUI;
import org.dclermonte.siba.model.SibaManager;
public class SibaCLI
{
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
public static void backup(final File directoryToSave, final String targetDirectory)
throws ArchiveException, IOException
{
File result;
result = SibaManager.backup(directoryToSave, targetDirectory);
System.out.println(BUNDLE.getString("BackupPanel.confirmDialogMessage.text") + result.getName());
return;
}
public static void check(final File fileToCheck) throws NoSuchAlgorithmException, IOException
{
boolean result;
result = SibaManager.check(fileToCheck);
String yourFile = BUNDLE.getString("CheckPanel.confirmDialogYourString.text");
String good = BUNDLE.getString("CheckPanel.confirmDialogGood.text");
String bad = BUNDLE.getString("CheckPanel.confirmDialogBad.text");
if (result)
{
System.out.println(yourFile + fileToCheck.getName() + good);
}
else
{
System.out.println(yourFile + fileToCheck.getName() + bad);
}
return;
}
public static void help()
{
System.out.println("usage : ");
System.out.println("Siba : ");
System.out.println("Siba [-h |-help| --help]");
System.out.println("siba -backup -directoryToSave [-target]");
System.out.println("siba -check [-filename | -file.tgz | -file.md5]");
System.out.println("siba -backup directoryToSave [-target]");
System.out.println("siba -check [filename | file.tgz | file.md5]");
}
public static void main(final String[] args)
public static void main(final String[] args) throws ArchiveException, IOException, NoSuchAlgorithmException
{
if (args.length == 0)
int numberParameter = args.length;
switch (numberParameter)
{
SibaGUI.main(args);
}
for (String arg : args)
{
if (arg.equals("-h") || args.equals("-help") || args.equals("--help"))
{
case 0:
SibaGUI.main(args);
break;
case 1:
help();
break;
}
if (arg.equals("-backup"))
{
case 2:
if (args[0].equals("-backup"))
{
File directoryToSave = new File(args[1]);
if (directoryToSave.exists())
{
}
backup(directoryToSave, directoryToSave.getParent());
System.out.println(BUNDLE.getString("BackupPanel.parentDirectory.text"));
return;
}
}
if (args[0].equals("-check"))
{
File fileToCheck = new File(args[1]);
if (fileToCheck.exists())
{
check(fileToCheck);
return;
}
}
else
{
help();
}
break;
case 3:
if (args[0].equals("-backup"))
{
File directoryToSave = new File(args[1]);
if (directoryToSave.exists())
{
backup(directoryToSave, args[2]);
return;
}
}
else
{
help();
}
break;
default:
help();
break;
}
}
}

View File

@ -34,6 +34,11 @@ import javax.swing.JTextPane;
public class AboutDialog extends JDialog
{
/**
*
*/
private static final long serialVersionUID = 8868109575782482455L;
/**
* Launch the application.
*/

View File

@ -27,4 +27,5 @@ CheckPanel.confirmDialogYourString.text = Your File
CheckPanel.confirmDialogGood.text = has been check and is good
CheckPanel.confirmDialogBad.text = is corrupted
BackupPanel.dataMissing.text = Data Missing
BackupPanel.TitleWarning.text = Warning
BackupPanel.TitleWarning.text = Warning
BackupPanel.parentDirectory.text= Your backup File is in the parent directory

View File

@ -27,4 +27,5 @@ CheckPanel.confirmDialogYourString.text = Votre fichier
CheckPanel.confirmDialogGood.text = a été vérifié et ne comporte pas d'erreurs
CheckPanel.confirmDialogBad.text = comporte des erreurs
BackupPanel.dataMissing.text = Données incomplètes
BackupPanel.TitleWarning.text = Attention
BackupPanel.TitleWarning.text = Attention
BackupPanel.parentDirectory.text= Votre fichier de sauvegarde est dans le répertoire parent

View File

@ -31,7 +31,6 @@ import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ResourceBundle;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
@ -41,7 +40,6 @@ import org.apache.commons.compress.utils.IOUtils;
public class SibaManager
{
private static final ResourceBundle BUNDLE = ResourceBundle.getBundle("org.dclermonte.siba.gui.messages"); //$NON-NLS-1$
public static File backup(final File fileToSave, final String target) throws ArchiveException, IOException
{