added SibaCLI
This commit is contained in:
parent
cf30fed8bb
commit
8b208a14e0
BIN
lib/Siba.jar
BIN
lib/Siba.jar
Binary file not shown.
@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
java -jar Siba.jar $1 $2
|
java -jar Siba.jar $1 $2 $3 $4
|
||||||
|
|
||||||
|
@ -19,13 +19,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.dclermonte.siba;
|
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.cli.SibaCLI;
|
||||||
import org.dclermonte.siba.gui.SibaGUI;
|
import org.dclermonte.siba.gui.SibaGUI;
|
||||||
|
|
||||||
public class Siba
|
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)
|
if (args.length == 0)
|
||||||
|
@ -19,42 +19,114 @@
|
|||||||
*/
|
*/
|
||||||
package org.dclermonte.siba.cli;
|
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.gui.SibaGUI;
|
||||||
|
import org.dclermonte.siba.model.SibaManager;
|
||||||
|
|
||||||
public class SibaCLI
|
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()
|
public static void help()
|
||||||
{
|
{
|
||||||
|
|
||||||
System.out.println("usage : ");
|
System.out.println("usage : ");
|
||||||
System.out.println("Siba : ");
|
System.out.println("Siba : ");
|
||||||
System.out.println("Siba [-h |-help| --help]");
|
System.out.println("Siba [-h |-help| --help]");
|
||||||
System.out.println("siba -backup -directoryToSave [-target]");
|
System.out.println("siba -backup directoryToSave [-target]");
|
||||||
System.out.println("siba -check [-filename | -file.tgz | -file.md5]");
|
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)
|
||||||
{
|
{
|
||||||
|
case 0:
|
||||||
SibaGUI.main(args);
|
SibaGUI.main(args);
|
||||||
}
|
break;
|
||||||
for (String arg : args)
|
case 1:
|
||||||
{
|
|
||||||
|
|
||||||
if (arg.equals("-h") || args.equals("-help") || args.equals("--help"))
|
|
||||||
{
|
|
||||||
help();
|
help();
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
if (arg.equals("-backup"))
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,11 @@ import javax.swing.JTextPane;
|
|||||||
public class AboutDialog extends JDialog
|
public class AboutDialog extends JDialog
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 8868109575782482455L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch the application.
|
* Launch the application.
|
||||||
*/
|
*/
|
||||||
|
@ -27,4 +27,5 @@ CheckPanel.confirmDialogYourString.text = Your File
|
|||||||
CheckPanel.confirmDialogGood.text = has been check and is good
|
CheckPanel.confirmDialogGood.text = has been check and is good
|
||||||
CheckPanel.confirmDialogBad.text = is corrupted
|
CheckPanel.confirmDialogBad.text = is corrupted
|
||||||
BackupPanel.dataMissing.text = Data Missing
|
BackupPanel.dataMissing.text = Data Missing
|
||||||
BackupPanel.TitleWarning.text = Warning
|
BackupPanel.TitleWarning.text = Warning
|
||||||
|
BackupPanel.parentDirectory.text= Your backup File is in the parent directory
|
@ -27,4 +27,5 @@ CheckPanel.confirmDialogYourString.text = Votre fichier
|
|||||||
CheckPanel.confirmDialogGood.text = a été vérifié et ne comporte pas d'erreurs
|
CheckPanel.confirmDialogGood.text = a été vérifié et ne comporte pas d'erreurs
|
||||||
CheckPanel.confirmDialogBad.text = comporte des erreurs
|
CheckPanel.confirmDialogBad.text = comporte des erreurs
|
||||||
BackupPanel.dataMissing.text = Données incomplètes
|
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
|
@ -31,7 +31,6 @@ import java.security.MessageDigest;
|
|||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
|
|
||||||
import org.apache.commons.compress.archivers.ArchiveException;
|
import org.apache.commons.compress.archivers.ArchiveException;
|
||||||
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
|
||||||
@ -41,7 +40,6 @@ import org.apache.commons.compress.utils.IOUtils;
|
|||||||
|
|
||||||
public class SibaManager
|
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
|
public static File backup(final File fileToSave, final String target) throws ArchiveException, IOException
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user