Example #1
0
        public static void Main(string[] args)
        {
            var authManager = new AuthManager(args);

            client = authManager.Connect().Result;

            var command = Console.ReadLine();

            while (command != "exit")
            {
                try
                {
                    var exitCode = Parser.Default.ParseArguments<
                        StatsOptions,
                        PutOptions,
                        GetOptions,
                        ListOptions,
                        ExportOptions,
                        ImportOptions,
                        DeleteOptions>(command.ParseArguments()).MapResult(
                        (StatsOptions opts) => StatsCommand.Run(opts, client),
                        (PutOptions opts) => PutCommand.Run(opts, client),
                        (GetOptions opts) => GetCommand.Run(opts, client),
                        (ListOptions opts) => ListCommand.Run(opts, client),
                        (ExportOptions opts) => ExportCommand.Run(opts, client, authManager),
                        (ImportOptions opts) => ImportCommand.Run(opts, client, authManager),
                        (DeleteOptions opts) => DeleteCommand.Run(opts, client),
                        errs => 1);
                }
                catch (Exception ex)
                {
                    Logger.LogError(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
                }

                command = Console.ReadLine();
            }
        }
Example #2
0
        public static int Run(ExportOptions options, Client client, AuthManager authManager)
        {
            string exportDir = options.Path ?? Directory.GetCurrentDirectory();

            if (string.IsNullOrEmpty(options.Container))
            {
                var accountData = client.GetAccount().Result;
                if (accountData.IsSuccess)
                {
                    if (accountData.Containers != null && accountData.Containers.Count > 0)
                    {
                        var exporter = new Exporter(client, authManager.Credentials());

                        if (string.IsNullOrEmpty(options.Prefix))
                        {
                            exporter.GetObjects(accountData.Containers, exportDir);
                        }
                        else
                        {
                            exporter.GetObjectsWithPrefix(options.Prefix, accountData.Containers, exportDir);
                        }
                    }
                    else
                    {
                        Console.WriteLine("No containers found");
                    }
                }
                else
                {
                    Logger.LogError(accountData.Reason);
                }
            }

            return 0;
        }
Example #3
0
        public static int Run(ImportOptions options, Client client, AuthManager authManager)
        {
            string importDir = options.Path ?? Directory.GetCurrentDirectory();

            var importer = new Importer(authManager.Credentials(), importDir);

            importer.PutObjects();

            return 0;   
        }