コード例 #1
0
ファイル: Commands.cs プロジェクト: bluemarsh/talys
        public override int Execute()
        {
            if (!TryParseCommonArgs(Store, out var flowContext))
            {
                return(1);
            }

            Console.WriteLine($"Fetching {Tables} and merging to {flowContext.LocalStore.Location}");

            var flow = new PullFlow(flowContext);

            return(flow.TryExecute() ? 0 : 1);
        }
コード例 #2
0
        public bool TryExecute()
        {
            IEnumerable <string> tables;

            if (_context.Tables.Count > 0)
            {
                tables = _context.Tables;
            }
            else
            {
                tables = _context.Config.Tables.Keys;
            }

            // TODO: create all table metadata upfront, so that subsequent "pull" will complete interrupted clone
            // separate the init code here into an "init" command ("clone" is just init + pull)
            foreach (string table in tables)
            {
                if (!_context.Config.Tables.TryGetValue(table, out var tableConfig))
                {
                    Console.WriteLine($"Unknown table: {table}");
                    return(false);
                }

                var metadata = new Metadata
                {
                    Config = tableConfig,
                };

                if (!_context.LocalStore.TryInitialize(table, metadata))
                {
                    return(false);
                }

                var tableContext = _context.WithTables(new[] { table });

                var pullFlow = new PullFlow(tableContext);
                if (!pullFlow.TryExecute())
                {
                    return(false);
                }
            }

            return(true);
        }