Esempio n. 1
0
        private async Task <int> OnExecute(BaseOptions baseOptions, XRayBuildOptions xrayBuildOptions, CancellationToken cancellationToken)
        {
            var config = new XRayBuilderConfig
            {
                UseSubdirectories   = baseOptions.UseSubdirectories.HasValue(),
                BaseOutputDirectory = baseOptions.BaseOutputDirectory.HasValue()
                    ? baseOptions.BaseOutputDirectory.Value()
                    : $"{AppDomain.CurrentDomain.BaseDirectory ?? Environment.CurrentDirectory}out",
                BuildForAndroid = baseOptions.Android.HasValue(),
                OutputToSidecar = baseOptions.OutputToSidecar.HasValue()
            };

            await using var container = _bootstrap(config);
            var logger = container.GetInstance <ILogger>();

            var bookPath = (string)baseOptions.Book.Value;

            if (bookPath == null || !File.Exists(bookPath))
            {
                logger.Log($"Book not found: {bookPath}");
                return(1);
            }

            var xrayBuildService = container.GetInstance <XRay>();
            var request          = new XRay.Request(
                bookPath: bookPath,
                dataUrl: xrayBuildOptions.DataUrl.Value() ?? SecondarySourceRoentgen.FakeUrl,
                includeTopics: xrayBuildOptions.IncludeTopics.HasValue(),
                splitAliases: xrayBuildOptions.SplitAliases.HasValue(),
                amazonTld: baseOptions.AmazonTld.Value());
            var xrayPath = await xrayBuildService.BuildAsync(request, cancellationToken);

            return(0);
        }
Esempio n. 2
0
 public DirectoryService(ILogger logger, XRayBuilderConfig config)
 {
     _logger = logger;
     _config = config;
 }