|
@@ -0,0 +1,86 @@
|
|
|
+
|
|
|
+public static int main(string[] args) {
|
|
|
+
|
|
|
+ if(args.length < 2) {
|
|
|
+ usage();
|
|
|
+ return 255;
|
|
|
+ }
|
|
|
+
|
|
|
+ var command = args[1];
|
|
|
+ if(command == "check") {
|
|
|
+ if(args.length != 3) {
|
|
|
+ check_usage();
|
|
|
+ return 255;
|
|
|
+ }
|
|
|
+ if(args[2] != "current" && args[2] != "latest") {
|
|
|
+ check_usage();
|
|
|
+ return 255;
|
|
|
+ }
|
|
|
+
|
|
|
+ return do_check(args[2]);
|
|
|
+ }
|
|
|
+ if(command == "repair") {
|
|
|
+ return do_repair();
|
|
|
+ }
|
|
|
+ if(command == "refresh") {
|
|
|
+ return do_refresh();
|
|
|
+ }
|
|
|
+ if(command == "apply") {
|
|
|
+ return do_apply();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ usage();
|
|
|
+ return 255;
|
|
|
+}
|
|
|
+
|
|
|
+private void usage() {
|
|
|
+ printerr("USAGE:\n\tbinman check\n\tbinman repair\n\tbinman refresh\n\tbinman apply\n");
|
|
|
+}
|
|
|
+
|
|
|
+private void check_usage() {
|
|
|
+ printerr("USAGE:\n\tbinman check current\n\tbinman check latest\n");
|
|
|
+}
|
|
|
+
|
|
|
+private int do_check(string type) {
|
|
|
+ // var applicator = new Binman.Applicator(Binman.ApplicationType.get_mapper().materialise(type));
|
|
|
+ // var files = applicator.get_file_details();
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+private int do_repair() {
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
+private string last_refresh_component_name;
|
|
|
+private int do_refresh() {
|
|
|
+ try {
|
|
|
+ print(@"0.00% - Reading composition...\r");
|
|
|
+ var refresher = new Binman.Updater();
|
|
|
+ var components = Binman.get_composition();
|
|
|
+ last_refresh_component_name = "";
|
|
|
+ refresher.progress_updated.connect((cn, cc, ct, bd, bt) => {
|
|
|
+ if(last_refresh_component_name != cn) {
|
|
|
+ print("\n");
|
|
|
+ }
|
|
|
+ var frac = ((float)cc) / ((float)ct);
|
|
|
+ if(bt != null) {
|
|
|
+ frac += (((float)bd) / ((float)bt) * (1.0f / (float)ct));
|
|
|
+ }
|
|
|
+
|
|
|
+ print(@"$(frac.to_string("%.2f"))% - Downloading manifest $(cn)\r");
|
|
|
+ });
|
|
|
+ refresher.update(components.to_series());
|
|
|
+ print("\nComplete!\n");
|
|
|
+ }
|
|
|
+ catch(Error e) {
|
|
|
+ printerr(@"Failed to refresh manifests: $(e.message)\n");
|
|
|
+ return e.code;
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+private int do_apply() {
|
|
|
+ return -1;
|
|
|
+}
|