devrc 0.6.0

devrc is an easy to use task runner tool on steroids for developers
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
use std::{cell::RefCell, convert::TryFrom, env, fs, io::Read, path::PathBuf, time::Duration};

use devrc_core::{logging::LogLevel, workshop::Designer};
use indexmap::IndexMap;
use reqwest::header::{HeaderMap, HeaderName, HeaderValue};
use url::Url;

use crate::{
    auth::Auth,
    cache::Cache,
    devrcfile::Devrcfile,
    docs::DocHelper,
    errors::{DevrcError, DevrcResult},
    include::{FileInclude, Include, UrlInclude},
    interrupt::setup_interrupt_handler,
    loader::LoadingConfig,
    raw::devrcfile::{Kind, RawDevrcfile},
    registry::Registry,
    resolver::{Location, PathResolve},
    scope::Scope,
    tasks::arguments::TaskArguments,
    utils,
    utils::{
        get_absolute_path, get_directory_devrc_file, get_global_devrc_file,
        get_local_user_defined_devrc_file,
    },
    variables::RawVariables,
};

use sha256::digest;

use std::{fmt::Debug, rc::Rc};

use std::io;

const DEFAULT_MAX_NESTING_LEVEL: u32 = 10;

use devrc_plugins::execution::ExecutionPluginManager;

#[derive(Debug)]
pub struct Runner {
    pub files: Vec<PathBuf>,
    use_global: bool,
    dry_run: bool,
    rest: Vec<String>,

    /// Assembled tasks library
    pub devrc: Devrcfile,

    pub global_loaded: bool,

    pub loaded_locations: Vec<Location>,

    pub log_level: Option<LogLevel>,
    pub designer: Designer,

    pub global_scope: Rc<RefCell<Scope>>,

    pub registry: Registry,

    pub max_nesting_level: u32,

    pub execution_plugin_registry: Rc<RefCell<ExecutionPluginManager>>,

    pub cache: Cache,
}

impl Runner {
    pub fn new() -> Self {
        let files: Vec<PathBuf> = Vec::new();
        let scope = Rc::new(RefCell::new(Scope {
            name: "devrcfile".to_string(),
            ..Default::default()
        }));
        let plugin_manager = Rc::new(RefCell::new(ExecutionPluginManager::new()));
        let devrcfile = Devrcfile::with_scope(Rc::clone(&scope))
            .with_execution_plugin_manager(Rc::clone(&plugin_manager));

        Runner {
            files,
            use_global: false,
            dry_run: false,
            rest: vec![],
            devrc: devrcfile,
            global_loaded: false,
            loaded_locations: vec![],
            log_level: Some(LogLevel::Info),
            designer: Designer::default(),
            global_scope: scope,
            registry: Registry::default(),
            max_nesting_level: DEFAULT_MAX_NESTING_LEVEL,
            execution_plugin_registry: plugin_manager,
            cache: Cache::default(),
        }
    }

    pub fn setup_dry_run(&mut self, dry_run: bool) -> DevrcResult<()> {
        self.dry_run = dry_run;
        Ok(())
    }

    pub fn setup_verbosity(&mut self, level: u8, quiet: bool) -> DevrcResult<()> {
        match (quiet, level) {
            (true, _) => self.log_level = Some(LogLevel::Off),
            (_, x) => self.log_level = Some(LogLevel::from(x)),
        }
        Ok(())
    }

    pub fn setup_variables(&mut self, variables: RawVariables) -> DevrcResult<()> {
        self.devrc.process_variables(variables)
    }

    pub fn get_logger(&self) -> LogLevel {
        if let Some(level) = self.log_level.clone() {
            return level;
        }
        self.devrc.config.log_level.clone()
    }

    pub fn get_cache_ttl(&self) -> Option<Duration> {
        self.devrc.config.cache_ttl
    }

    pub fn load(&mut self) -> DevrcResult<()> {
        if let Some(level) = &self.log_level {
            self.devrc.setup_log_level(level.clone())?;
        }

        // Try to load global devrcfile if flag is enabled
        if self.use_global {
            self.load_global()?;
        }

        let loading_config = LoadingConfig::default()
            .with_log_level(self.get_logger())
            .with_cache_ttl(self.get_cache_ttl());

        // Load files only if option specified
        if !self.files.is_empty() {
            let files = self.files.clone();

            for file in files {
                self.load_file(file.to_path_buf(), loading_config.clone(), Kind::Args)?;
            }
        } else {
            if let Some(file) = get_directory_devrc_file() {
                if file.exists() {
                    // Try to load Devrcfile from current directory
                    self.load_file(file, loading_config.clone(), Kind::Directory)?;
                }
            }

            if let Some(file) = get_local_user_defined_devrc_file() {
                if file.exists() {
                    // Try to load Devrcfile.local
                    self.load_file(file, loading_config, Kind::DirectoryLocal)?;
                }
            }
        }

        self.devrc.setup_dry_run(self.dry_run)?;

        if let Some(level) = &self.log_level {
            self.devrc.setup_log_level(level.clone())?;
        }

        // Init plugins
        self.load_plugins()?;

        Ok(())
    }

    pub fn load_plugins(&mut self) -> DevrcResult<()> {
        let mut plugins_registry = (*self.execution_plugin_registry)
            .try_borrow_mut()
            .map_err(|_| DevrcError::RuntimeError)?;

        plugins_registry.setup_logger(self.get_logger());

        for (name, path) in self.devrc.config.plugins.clone().into_iter() {
            let abs_path = utils::get_absolute_path(&path, None)?;
            unsafe {
                if !abs_path.exists() {
                    return Err(DevrcError::PluginFileNotExists(abs_path));
                }
                plugins_registry.load_plugin(&name, abs_path.as_os_str(), self.get_logger())?;
            }
        }
        Ok(())
    }

    pub fn load_global(&mut self) -> DevrcResult<()> {
        if let Some(file) = get_global_devrc_file() {
            self.get_logger().debug(
                &format!("\n==> Loading GLOBAL: `{}` ...", &file.display()),
                &self.designer.banner(),
            );

            if file.exists() {
                let content = fs::read_to_string(&file).map_err(DevrcError::IoError)?;
                let location = Location::LocalFile(file);
                let loading_config = LoadingConfig::default().with_log_level(self.get_logger());

                self.load_from_str(&content, location, Kind::Global, loading_config)?;
                self.global_loaded = true;
            } else {
                return Err(DevrcError::FileNotExists(file));
            }
        }
        Ok(())
    }

    pub fn load_file(
        &mut self,
        file: PathBuf,
        loading_config: LoadingConfig,
        kind: Kind,
    ) -> DevrcResult<()> {
        self.get_logger().debug(
            &format!("\n==> Loading FILE: `{}` ...", &file.display()),
            &self.designer.banner(),
        );

        if loading_config.level > self.max_nesting_level {
            return Err(DevrcError::NestingLevelExceed);
        }

        if file.exists() {
            let content = fs::read_to_string(&file).map_err(DevrcError::IoError)?;
            let location = Location::LocalFile(file);
            self.load_from_str(&content, location, kind, loading_config)?;
        } else {
            return Err(DevrcError::FileNotExists(file));
        }

        Ok(())
    }

    pub fn load_stdin(&mut self) -> DevrcResult<()> {
        let mut buffer = String::new();
        io::stdin().read_to_string(&mut buffer)?;
        let loading_config = LoadingConfig::default()
            .with_log_level(self.get_logger())
            .with_cache_ttl(self.get_cache_ttl());
        self.load_from_str(&buffer, Location::StdIn, Kind::StdIn, loading_config)
    }

    pub fn load_from_str(
        &mut self,
        input: &str,
        location: Location,
        kind: Kind,
        loading_config: LoadingConfig,
    ) -> DevrcResult<()> {
        match RawDevrcfile::prepared_from_str(
            input,
            location.clone(),
            kind.clone(),
            loading_config.clone(),
        ) {
            Ok(raw_devrcfile) => {
                if matches!(&kind, Kind::Directory | Kind::DirectoryLocal | Kind::StdIn)
                    && raw_devrcfile.is_global_enabled()
                    && !self.global_loaded
                {
                    self.load_global()?
                }

                self.devrc.add_config(raw_devrcfile.config.clone(), &kind)?;

                self.load_include(
                    raw_devrcfile.clone(),
                    location,
                    loading_config.with_cache_ttl(self.get_cache_ttl()),
                )?;

                self.devrc.add_raw_devrcfile(raw_devrcfile.clone(), &kind)?;
                self.registry.add(raw_devrcfile)?;
            }
            Err(error) => return Err(error),
        }
        self.devrc.setup_dry_run(self.dry_run)?;

        if let Some(level) = &self.log_level {
            self.devrc.setup_log_level(level.clone())?;
        }
        Ok(())
    }

    pub fn load_url(
        &mut self,
        url: Url,
        loading_config: LoadingConfig,
        checksum: Option<&str>,
        headers: indexmap::IndexMap<String, String>,
        auth: Auth,
    ) -> DevrcResult<()> {
        let location = Location::Remote {
            url: url.clone(),
            auth: auth.clone(),
        };

        if let Some(cache_ttl) = self.get_cache_ttl() {
            if let Some(content) = crate::cache::load(&url, &loading_config, checksum, &cache_ttl) {
                self.get_logger().debug(
                    &format!("\n==> Loading URL CACHE: `{}` ...", &url),
                    &self.designer.banner(),
                );
                return self.load_from_str(&content, location, Kind::Include, loading_config);
            }
        }

        self.get_logger().debug(
            &format!("\n==> Loading URL: `{}` ...", &url),
            &self.designer.banner(),
        );

        let client = reqwest::blocking::Client::new();
        let mut headers_map: HeaderMap = HeaderMap::new();

        for (key, value) in headers {
            headers_map.insert(
                HeaderName::try_from(key.clone()).map_err(|_| {
                    DevrcError::UrlImportHeadersError {
                        name: key.clone(),
                        value: value.clone(),
                    }
                })?,
                HeaderValue::try_from(value.clone()).map_err(|_| {
                    DevrcError::UrlImportHeadersError {
                        name: key.clone(),
                        value: value.clone(),
                    }
                })?,
            );
        }

        if let Some((key, value)) = auth.get_header() {
            headers_map.insert(
                HeaderName::try_from(key.clone()).map_err(|_| {
                    DevrcError::UrlImportHeadersError {
                        name: key.clone(),
                        value: value.clone(),
                    }
                })?,
                HeaderValue::try_from(value.clone()).map_err(|_| {
                    DevrcError::UrlImportHeadersError {
                        name: key.clone(),
                        value: value.clone(),
                    }
                })?,
            );
        }

        match client.get(url.as_str()).headers(headers_map).send() {
            Ok(response) if response.status() == 200 => {
                let content = response.text().map_err(|_| DevrcError::RuntimeError)?;
                if let Some(control_checksum) = checksum {
                    let content_checksum = digest(content.as_str());

                    if control_checksum != content_checksum {
                        return Err(DevrcError::UrlImportChecksumError {
                            url: url.as_str().to_string(),
                            control_checksum: control_checksum.to_string(),
                            content_checksum,
                        });
                    }
                }

                match self.load_from_str(&content, location, Kind::Include, loading_config) {
                    Ok(_) => {
                        if self.get_cache_ttl().is_some() {
                            crate::cache::save(&url, &content)?;
                        }
                        Ok(())
                    }
                    Err(error) => Err(error),
                }
            }
            Ok(response) => {
                loading_config.log_level.debug(
                    &format!(
                        "Loading FILE error: invalid status code `{:}` ...",
                        response.status()
                    ),
                    &loading_config.designer.banner(),
                );
                Err(DevrcError::UrlImportStatusError {
                    url: url.as_str().to_string(),
                    status: response.status(),
                })
            }
            Err(error) => {
                return Err(DevrcError::UrlImportRequestError {
                    url: url.as_str().to_string(),
                    inner: error,
                })
            }
        }
    }

    pub fn load_include(
        &mut self,
        raw_devrcfile: RawDevrcfile,
        source: Location,
        config: LoadingConfig,
    ) -> DevrcResult<()> {
        for include in raw_devrcfile.include {
            match (include, source.clone()) {
                (Include::Empty, _) => {}
                (
                    Include::File(FileInclude {
                        file,
                        path_resolve: _,
                        checksum: _,
                    }),
                    Location::None | Location::StdIn,
                ) => {
                    let path = utils::get_absolute_path(&file.clone(), None)?;
                    self.load_file(
                        path.to_path_buf(),
                        config.clone().child().with_cache_ttl(self.get_cache_ttl()),
                        Kind::Include,
                    )?;
                }

                (
                    Include::File(FileInclude {
                        file,
                        path_resolve: _,
                        checksum: _,
                    }),
                    Location::LocalFile(ref base),
                ) => {
                    let path = utils::get_absolute_path(&file.clone(), Some(&base.clone()))?;
                    self.load_file(
                        path.to_path_buf(),
                        config.clone().child().with_cache_ttl(self.get_cache_ttl()),
                        Kind::Include,
                    )?;
                }
                (
                    Include::File(FileInclude {
                        file,
                        path_resolve,
                        checksum,
                    }),
                    Location::Remote { url, auth },
                ) => {
                    if file.is_absolute() {
                        let loading_config = config
                            .clone()
                            .with_log_level(self.get_logger())
                            .with_cache_ttl(self.get_cache_ttl());
                        self.load_file(file.to_path_buf(), loading_config, Kind::Include)?;
                    } else {
                        match path_resolve {
                            PathResolve::Relative => {
                                let path = file
                                    .clone()
                                    .into_os_string()
                                    .into_string()
                                    .map_err(|_| DevrcError::RuntimeError)?;
                                let include_url = url
                                    .clone()
                                    .join(&path)
                                    .map_err(|_| DevrcError::RuntimeError)?;

                                let loading_config = config
                                    .clone()
                                    .child()
                                    .with_log_level(self.get_logger())
                                    .with_cache_ttl(self.get_cache_ttl());
                                self.load_url(
                                    include_url,
                                    loading_config,
                                    checksum.as_deref(),
                                    IndexMap::new(),
                                    auth.clone(),
                                )?;
                            }
                            PathResolve::Pwd => {
                                let path = utils::get_absolute_path(
                                    &file.clone(),
                                    env::current_dir().ok().as_ref(),
                                )?;
                                self.load_file(
                                    path.to_path_buf(),
                                    config.clone().child(),
                                    Kind::Include,
                                )?;
                            }
                        }
                    }
                }
                (
                    Include::Url(UrlInclude {
                        url,
                        checksum,
                        headers,
                        ignore_errors,
                        auth: raw_auth,
                    }),
                    _,
                ) => {
                    let parsed_url =
                        Url::parse(&url).map_err(|_| DevrcError::InvalidIncludeUrl(url))?;
                    let auth = Auth::try_from(raw_auth)?;

                    if ignore_errors {
                        self.load_url(
                            parsed_url,
                            config.clone().child().with_cache_ttl(self.get_cache_ttl()),
                            Some(&checksum),
                            headers,
                            auth,
                        )
                        .ok();
                    } else {
                        self.load_url(
                            parsed_url,
                            config.clone().child().with_cache_ttl(self.get_cache_ttl()),
                            Some(&checksum),
                            headers,
                            auth,
                        )?;
                    }
                }
            }
        }

        Ok(())
    }

    pub fn add_loaded_file(&mut self, location: Location) -> DevrcResult<()> {
        self.loaded_locations.push(location);
        Ok(())
    }

    pub fn add_file(&mut self, file: PathBuf) -> DevrcResult<()> {
        match utils::get_absolute_path(&file, env::current_dir().ok().as_ref()) {
            Ok(path) => {
                self.files.push(path);
                Ok(())
            }
            Err(error) => Err(error),
        }
    }

    pub fn add_files(&mut self, files: &[PathBuf]) -> DevrcResult<()> {
        for file in files.iter() {
            self.add_file(file.to_path_buf())?;
        }
        Ok(())
    }

    /// Execute given commands
    pub fn run(&mut self, params: Vec<String>) -> DevrcResult<()> {
        self.rest = params;
        setup_interrupt_handler();
        self.devrc.run(&self.rest)
    }

    /// Show detailed tasks list with short descriptions
    pub fn list_tasks_detailed(&self) -> DevrcResult<()> {
        println!("Available tasks:");
        let offset = 2;
        let (max_taskname_width, _) = self.devrc.get_max_taskname_width();
        for (name, task) in self.devrc.get_tasks_docs() {
            let help = task.format_help()?;
            let parameters = task.format_parameters_help(&self.designer)?;

            if name.starts_with('_') {
                continue;
            }

            // TODO: Add colours
            if !help.is_empty() {
                println!("\n{:width$}# {}", "", help.trim_end(), width = offset);
            }

            println!(
                "{:width$}{}{:max_taskname_width$}{} {}",
                "",
                self.designer.task_name().prefix(),
                name,
                self.designer.task_name().suffix(),
                parameters,
                // help,
                width = offset,
                max_taskname_width = max_taskname_width
            );
        }

        Ok(())
    }

    /// Show tasks list with short descriptions
    pub fn list_tasks(&self) -> DevrcResult<()> {
        let offset = 2;
        let (max_taskname_width, _) = self.devrc.get_max_taskname_width();
        for (name, task) in self.devrc.get_tasks_docs() {
            let help = task.format_help()?;

            if name.starts_with('_') {
                continue;
            }

            let help_string = if help.is_empty() {
                "".to_string()
            } else {
                format!("# {}", help)
            };

            let parameters_marker = if task.has_parameters() {
                let color = self.designer.parameter_name();
                format!("{}*{}", color.prefix(), color.suffix())
            } else {
                " ".to_string()
            };

            println!(
                "{:width$}{}{:max_taskname_width$}{} {} {}",
                "",
                self.designer.task_name().prefix(),
                name,
                self.designer.task_name().suffix(),
                parameters_marker,
                help_string,
                // help,
                width = offset,
                max_taskname_width = max_taskname_width
            );
        }

        Ok(())
    }

    /// Show global variables and their computed values
    pub fn list_global_vars(&self) -> DevrcResult<()> {
        println!("List global devrc variables:");
        let scope = ((*self.devrc.scope)
            .try_borrow()
            .map_err(|_| DevrcError::RuntimeError)?)
        .clone();
        self.list_vars(&scope)
    }

    /// Show global environment variables and their computed values
    pub fn list_global_env_vars(&self) -> DevrcResult<()> {
        println!("List global devrc environment variables:");
        let scope = ((*self.devrc.scope)
            .try_borrow()
            .map_err(|_| DevrcError::RuntimeError)?)
        .clone();
        self.list_env_vars(&scope)
    }

    pub fn list_vars(&self, scope: &Scope) -> DevrcResult<()> {
        let max_variable_name_width = scope.variables.get_max_key_width();

        for (name, value) in &scope.variables {
            println!(
                "{:width$}{}{:max_variable_name_width$}{} = \"{}\"",
                "",
                self.designer.variable().prefix(),
                name.get_name(),
                self.designer.variable().suffix(),
                value.get_rendered_value(),
                width = 2,
                max_variable_name_width = max_variable_name_width
            );
        }
        Ok(())
    }

    pub fn list_env_vars(&self, scope: &Scope) -> DevrcResult<()> {
        let max_variable_name_width = scope.environment.get_max_key_width();

        for (name, value) in &scope.environment {
            println!(
                "{:width$}{}{:max_variable_name_width$}{} = \"{}\"",
                "",
                self.designer.evariable().prefix(),
                name,
                self.designer.evariable().suffix(),
                value,
                width = 2,
                max_variable_name_width = max_variable_name_width
            );
        }
        Ok(())
    }

    /// Load global devrc
    pub fn use_global(&mut self) {
        self.use_global = true;
    }

    /// Show description for given task, variable or environment variable
    pub fn describe(&self, params: Vec<String>) -> DevrcResult<()> {
        for name in params {
            let task = self.devrc.find_task(&name)?;
            println!(
                "Usage: {}\nDescription: {}",
                task.get_usage_help(&name, &self.designer)?,
                task.format_help()?,
                // width = 2,
            );

            if let Some(example) = task.get_example() {
                println!("Examples: \n{}", example);
            }
            println!();

            if self.log_level == Some(LogLevel::Debug) {
                println!("Task variables:");
                let scope = task.get_scope(
                    &name,
                    Rc::clone(&self.devrc.scope),
                    &TaskArguments::default(),
                )?;
                self.list_vars(&scope)?;
                println!();

                println!("Task environment variables:");
                self.list_env_vars(&scope)?;
                println!("\n");
            }
        }
        Ok(())
    }

    pub fn get_calculated_scope(&self, _scope: &Scope) {}

    pub fn diagnostic(&mut self, params: Vec<String>) {
        println!("Show diagnostic info:");

        self.rest = params;

        println!(
            "Global defined interpreter: `{:}`",
            &self.devrc.config.interpreter
        );

        if let Some(value) = get_global_devrc_file() {
            if value.exists() {
                println!("Global .devrc exists: {:?}", value);
            }
        }

        if let Some(value) = get_directory_devrc_file() {
            if value.exists() {
                println!("Local directory Devrcfile exists: {:?}", value);
            }
        }

        if let Some(value) = get_local_user_defined_devrc_file() {
            if value.exists() {
                println!("Local user defined Devrcfile.local exists: {:?}", value);
            }
        }

        for file in &self.files {
            if let Ok(file) = get_absolute_path(file, None) {
                if file.exists() {
                    println!("Given Devrcfile exists: {:?}", file);
                } else {
                    println!("Given Devrcfile not exists: {:?}", file);
                }
            } else {
                error!("Given Devrcfile with broken path: {:?}", &file);
            }
        }

        for file in &self.registry.files {
            println!("Loaded locations: {:?}", file.location);
        }

        dbg!(self);
    }
}

impl Default for Runner {
    fn default() -> Self {
        Self::new()
    }
}

// pub fn get_config<T>(file: &PathBuf) -> DevrcResult<T>
// where T: for<'de> Deserialize<'de>
// {
//     let contents = match fs::read_to_string(&file) {
//         Ok(value) => value,
//         Err(error) => {
//             panic!("Can't read config file: {:?}", &file);
//             return Err(DevrcError::IoError(error))
//         },
//     };

//     let config: T = match serde_yaml::from_str(&contents) {
//         Ok(value) => value,
//         Err(error) => return Err(DevrcError::YamlParseError(error))
//     };

//     Ok(config)
// }

#[cfg(test)]
mod tests {

    #[test]
    fn test_devrcfile() {}
}