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
//! # Prompt
//!
//! `prompt` is the module which takes care of processing the shell prompt

/*
*
*   Copyright (C) 2020 Christian Visintin - christian.visintin1997@gmail.com
*
* 	This file is part of "Pyc"
*
*   Pyc is free software: you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*
*   Pyc is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   You should have received a copy of the GNU General Public License
*   along with Pyc.  If not, see <http://www.gnu.org/licenses/>.
*
*/

extern crate regex;

mod cache;
mod modules;

use super::ShellProps;
use crate::config::PromptConfig;
use crate::translator::ioprocessor::IOProcessor;
use cache::PromptCache;
use modules::*;

use regex::Regex;
use std::time::Duration;

const PROMPT_KEY_REGEX: &str = r"\$\{(.*?)\}";
//Prompt standard keys
const PROMPT_USER: &str = "${USER}";
const PROMPT_HOSTNAME: &str = "${HOSTNAME}";
const PROMPT_WRKDIR: &str = "${WRKDIR}";
const PROMPT_CMDTIME: &str = "${CMD_TIME}";
const PROMPT_RC: &str = "${RC}";

/// ## ShellPrompt
///
/// ShellPrompt is the struct which contains the current shell prompt configuration
pub struct ShellPrompt {
    prompt_line: String,
    translate: bool,
    break_opt: Option<BreakOptions>,
    duration_opt: Option<DurationOptions>,
    rc_opt: Option<RcOptions>,
    git_opt: Option<GitOptions>,
    cache: PromptCache,
}

/// ## ShellPrompt
///
/// ShellPrompt is the struct which contains the current shell prompt configuration
struct BreakOptions {
    pub break_with: String,
}

/// ## DurationOptions
///
/// DurationOptions is the struct which contains the current duration configuration
struct DurationOptions {
    pub minimum: Duration,
}

/// ## RcOptions
///
/// RcOptions is the struct which contains the return code configuration
struct RcOptions {
    pub ok: String,
    pub err: String,
}

/// ## GitOptions
///
/// GitOptions is the struct which contains the current git module configuration
struct GitOptions {
    pub branch: String,
    pub commit_ref_len: usize,
}

impl ShellPrompt {
    /// ### new
    ///
    /// Instantiate a new ShellPrompt with the provided parameters
    pub(super) fn new(prompt_opt: &PromptConfig) -> ShellPrompt {
        let break_opt: Option<BreakOptions> = match prompt_opt.break_enabled {
            true => Some(BreakOptions::new(&prompt_opt.break_str)),
            false => None,
        };
        let duration_opt: Option<DurationOptions> =
            match DurationOptions::should_enable(&prompt_opt.prompt_line) {
                true => Some(DurationOptions::new(prompt_opt.min_duration)),
                false => None,
            };
        let rc_opt: Option<RcOptions> = match RcOptions::should_enable(&prompt_opt.prompt_line) {
            true => Some(RcOptions::new(&prompt_opt.rc_ok, &prompt_opt.rc_err)),
            false => None,
        };
        let git_opt: Option<GitOptions> = match GitOptions::should_enable(&prompt_opt.prompt_line) {
            true => Some(GitOptions::new(
                &prompt_opt.git_branch,
                prompt_opt.git_commit_ref,
            )),
            false => None,
        };
        ShellPrompt {
            prompt_line: prompt_opt.prompt_line.clone(),
            translate: prompt_opt.translate,
            break_opt: break_opt,
            duration_opt: duration_opt,
            rc_opt: rc_opt,
            git_opt: git_opt,
            cache: PromptCache::new(),
        }
    }

    /// ### get_line
    ///
    /// get prompt line with resolved values
    pub(super) fn get_line(&mut self, shell_props: &ShellProps, processor: &IOProcessor) -> String {
        let mut prompt_line: String = self.process_prompt(shell_props, processor);
        //Translate prompt if necessary
        if self.translate {
            prompt_line = processor.text_to_cyrillic(&prompt_line);
        }
        //Write prompt
        prompt_line
    }

    /// ### process_prompt
    ///
    /// Process prompt keys and resolve prompt line
    /// Returns the processed prompt line
    /// This function is optimized to try to cache the previous values
    fn process_prompt(&mut self, shell_props: &ShellProps, processor: &IOProcessor) -> String {
        let mut prompt_line: String = self.prompt_line.clone();
        //Iterate over keys through regex ```\${(.*?)}```
        lazy_static! {
            static ref RE: Regex = Regex::new(PROMPT_KEY_REGEX).unwrap();
        }
        for regex_match in RE.captures_iter(prompt_line.clone().as_str()) {
            let mtch: String = String::from(&regex_match[0]);
            let replace_with: String = self.resolve_key(shell_props, processor, &mtch);
            prompt_line = prompt_line.replace(mtch.as_str(), replace_with.as_str());
        }
        //Trim prompt line
        prompt_line = String::from(prompt_line.trim());
        //If break, break line
        if let Some(brkopt) = &self.break_opt {
            prompt_line += "\n";
            prompt_line += brkopt.break_with.trim();
        }
        //Invalidate cache
        self.cache.invalidate();
        //Return prompt line
        prompt_line
    }

    /// ### resolve_key
    ///
    /// Replace the provided key with the resolved value
    fn resolve_key(
        &mut self,
        shell_props: &ShellProps,
        processor: &IOProcessor,
        key: &String,
    ) -> String {
        match key.as_str() {
            PROMPT_CMDTIME => {
                match &self.duration_opt {
                    Some(opt) => {
                        if shell_props.elapsed_time.as_millis() >= opt.minimum.as_millis() {
                            let millis: u128 = shell_props.elapsed_time.as_millis();
                            let secs: f64 = (millis as f64 / 1000 as f64) as f64;
                            String::from(format!("took {:.1}s", secs))
                        } else {
                            String::from("")
                        }
                    }
                    None => String::from(""),
                }
            }
            modules::git::PROMPT_GIT_BRANCH => {
                if self.git_opt.is_none() {
                    return String::from("");
                }
                //If repository is not cached, find repository
                if self.cache.get_cached_git().is_none() {
                    let repo_opt = git::find_repository(&shell_props.wrkdir);
                    match repo_opt {
                        Some(repo) => self.cache.cache_git(repo),
                        None => return String::from(""),
                    };
                }
                //Get branch (unwrap without fear; can't be None here)
                let branch: String = match git::get_branch(self.cache.get_cached_git().unwrap()) {
                    Some(branch) => branch,
                    None => return String::from(""),
                };
                //Format branch
                String::from(format!(
                    "{}{}",
                    self.git_opt.as_ref().unwrap().branch.clone(),
                    branch
                ))
            }
            modules::git::PROMPT_GIT_COMMIT => {
                if self.git_opt.is_none() {
                    return String::from("");
                }
                //If repository is not cached, find repository
                if self.cache.get_cached_git().is_none() {
                    let repo_opt = git::find_repository(&shell_props.wrkdir);
                    match repo_opt {
                        Some(repo) => self.cache.cache_git(repo),
                        None => return String::from(""),
                    };
                }
                //Get commit (unwrap without fear; can't be None here)
                match git::get_commit(
                    self.cache.get_cached_git().unwrap(),
                    self.git_opt.as_ref().unwrap().commit_ref_len,
                ) {
                    Some(commit) => commit,
                    None => String::from(""),
                }
            }
            PROMPT_HOSTNAME => shell_props.hostname.clone(),
            modules::colors::PROMPT_KBLK | modules::colors::PROMPT_KBLU | modules::colors::PROMPT_KCYN | modules::colors::PROMPT_KGRN | modules::colors::PROMPT_KGRY | modules::colors::PROMPT_KMAG | modules::colors::PROMPT_KRED | modules::colors::PROMPT_KRST | modules::colors::PROMPT_KWHT | modules::colors::PROMPT_KYEL => colors::PromptColor::from_key(key.as_str()).to_string(),
            modules::language::PROMPT_LANG => language::language_to_str(processor.language),
            PROMPT_RC => match &self.rc_opt {
                Some(opt) => match shell_props.exit_status {
                    0 => opt.ok.clone(),
                    _ => opt.err.clone(),
                },
                None => String::from(""),
            },
            PROMPT_USER => shell_props.username.clone(),
            PROMPT_WRKDIR => shell_props.wrkdir.as_path().display().to_string(),
            _ => key.clone(), //Keep unresolved keys
        }
    }
}

impl BreakOptions {
    /// ### new
    ///
    /// Instantiate a new BreakOptions with the provided parameters
    pub fn new(break_with: &String) -> BreakOptions {
        BreakOptions {
            break_with: break_with.clone(),
        }
    }
}

impl DurationOptions {
    /// ### should_enable
    ///
    /// helper which says if duration module should be enabled
    pub fn should_enable(prompt_line: &String) -> bool {
        prompt_line.contains(PROMPT_CMDTIME)
    }

    /// ### new
    ///
    /// Instantiate a new DurationOptions with the provided parameters
    pub fn new(min_duration: usize) -> DurationOptions {
        DurationOptions {
            minimum: Duration::from_millis(min_duration as u64),
        }
    }
}

impl RcOptions {
    /// ### should_enable
    ///
    /// helper which says if rc module should be enabled
    pub fn should_enable(prompt_line: &String) -> bool {
        prompt_line.contains(PROMPT_RC)
    }

    /// ### new
    ///
    /// Instantiate a new RcOptions with the provided parameters
    pub fn new(ok_str: &String, err_str: &String) -> RcOptions {
        RcOptions {
            ok: ok_str.clone(),
            err: err_str.clone(),
        }
    }
}

impl GitOptions {
    /// ### should_enable
    ///
    /// helper which says if git module should be enabled
    pub fn should_enable(prompt_line: &String) -> bool {
        prompt_line.contains(modules::git::PROMPT_GIT_BRANCH) || prompt_line.contains(modules::git::PROMPT_GIT_COMMIT)
    }

    /// ### new
    ///
    /// Instantiate a new GitOptions with the provided parameters
    pub fn new(branch: &String, commit: usize) -> GitOptions {
        GitOptions {
            branch: branch.clone(),
            commit_ref_len: commit,
        }
    }
}

#[cfg(test)]
mod tests {

    use super::*;
    use crate::config::PromptConfig;
    use crate::translator::ioprocessor::IOProcessor;
    use crate::translator::new_translator;
    use crate::translator::lang::Language;
    use colors::PromptColor;

    use git2::Repository;
    use std::path::PathBuf;
    use std::time::Duration;

    #[test]
    fn test_prompt_simple() {
        let prompt_config_default = PromptConfig::default();
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let shellenv: ShellProps = get_shellenv();
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "{}@{}:{}$",
            shellenv.username.clone(),
            shellenv.hostname.clone(),
            shellenv.wrkdir.display()
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_colors() {
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line = String::from("${KRED}RED${KYEL}YEL${KBLU}BLU${KGRN}GRN${KWHT}WHT${KGRY}GRY${KBLK}BLK${KMAG}MAG${KCYN}CYN${KRST}");
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let shellenv: ShellProps = get_shellenv();
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "{}RED{}YEL{}BLU{}GRN{}WHT{}GRY{}BLK{}MAG{}CYN{}",
            PromptColor::Red.to_string(),
            PromptColor::Yellow.to_string(),
            PromptColor::Blue.to_string(),
            PromptColor::Green.to_string(),
            PromptColor::White.to_string(),
            PromptColor::Gray.to_string(),
            PromptColor::Black.to_string(),
            PromptColor::Magenta.to_string(),
            PromptColor::Cyan.to_string(),
            PromptColor::Reset.to_string()
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_lang_time_with_break() {
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line = String::from("${LANG} ~ ${KYEL}${USER}${KRST} on ${KGRN}${HOSTNAME}${KRST} in ${KCYN}${WRKDIR}${KRST} ${KYEL}${CMD_TIME}${KRST}");
        prompt_config_default.break_enabled = true;
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let mut shellenv: ShellProps = get_shellenv();
        shellenv.elapsed_time = Duration::from_millis(5100);
        shellenv.wrkdir = PathBuf::from("/tmp/");
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "{} ~ {}{}{} on {}{}{} in {}{}{} {}took 5.1s{}\n❯",
            language::language_to_str(Language::Russian),
            PromptColor::Yellow.to_string(),
            shellenv.username.clone(),
            PromptColor::Reset.to_string(),
            PromptColor::Green.to_string(),
            shellenv.hostname.clone(),
            PromptColor::Reset.to_string(),
            PromptColor::Cyan.to_string(),
            shellenv.wrkdir.display(),
            PromptColor::Reset.to_string(),
            PromptColor::Yellow.to_string(),
            PromptColor::Reset.to_string()
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_git() {
        //Get current git info
        //Initialize module
        let repo: Repository = git::find_repository(&PathBuf::from("./")).unwrap();
        //Branch should be none
        let branch: String = git::get_branch(&repo).unwrap();
        let commit: String = git::get_commit(&repo, 8).unwrap();
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line =
            String::from("${USER}@${HOSTNAME}:${WRKDIR} ${GIT_BRANCH}:${GIT_COMMIT}");
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let mut shellenv: ShellProps = get_shellenv();
        shellenv.elapsed_time = Duration::from_millis(5100);
        shellenv.wrkdir = PathBuf::from("./");
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "{}@{}:{} on {}:{}",
            shellenv.username.clone(),
            shellenv.hostname.clone(),
            shellenv.wrkdir.display(),
            branch,
            commit
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_git_not_in_repo() {
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line =
            String::from("${USER}@${HOSTNAME}:${WRKDIR} ${GIT_BRANCH} ${GIT_COMMIT}");
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let mut shellenv: ShellProps = get_shellenv();
        shellenv.elapsed_time = Duration::from_millis(5100);
        shellenv.wrkdir = PathBuf::from("/");
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "{}@{}:{}",
            shellenv.username.clone(),
            shellenv.hostname.clone(),
            shellenv.wrkdir.display()
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_rc_ok() {
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line = String::from("${RC} ${USER}@${HOSTNAME}:${WRKDIR}");
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let mut shellenv: ShellProps = get_shellenv();
        shellenv.elapsed_time = Duration::from_millis(5100);
        shellenv.wrkdir = PathBuf::from("/");
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "✔ {}@{}:{}",
            shellenv.username.clone(),
            shellenv.hostname.clone(),
            shellenv.wrkdir.display()
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_rc_error() {
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line = String::from("${RC} ${USER}@${HOSTNAME}:${WRKDIR}");
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let mut shellenv: ShellProps = get_shellenv();
        shellenv.elapsed_time = Duration::from_millis(5100);
        shellenv.wrkdir = PathBuf::from("/");
        shellenv.exit_status = 255;
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "✖ {}@{}:{}",
            shellenv.username.clone(),
            shellenv.hostname.clone(),
            shellenv.wrkdir.display()
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    #[test]
    fn test_prompt_unresolved() {
        let mut prompt_config_default = PromptConfig::default();
        //Update prompt line
        prompt_config_default.prompt_line = String::from("${USER}@${HOSTNAME}:${WRKDIR} ${FOOBAR}");
        let mut prompt: ShellPrompt = ShellPrompt::new(&prompt_config_default);
        let iop: IOProcessor = get_ioprocessor();
        let mut shellenv: ShellProps = get_shellenv();
        shellenv.elapsed_time = Duration::from_millis(5100);
        shellenv.wrkdir = PathBuf::from("/");
        shellenv.exit_status = 255;
        //Print first in latin
        let _ = prompt.get_line(&shellenv, &iop);
        prompt.translate = true;
        //Then in cyrillic
        let _ = prompt.get_line(&shellenv, &iop);
        //Get prompt line
        let prompt_line: String = prompt.process_prompt(&shellenv, &iop);
        let expected_prompt_line = String::from(format!(
            "{}@{}:{} {}",
            shellenv.username.clone(),
            shellenv.hostname.clone(),
            shellenv.wrkdir.display(),
            "${FOOBAR}"
        ));
        assert_eq!(prompt_line, expected_prompt_line);
        //Terminate shell at the end of a test
        //terminate_shell(&mut shellenv);
        println!("\n");
    }

    fn get_ioprocessor() -> IOProcessor {
        IOProcessor::new(Language::Russian, new_translator(Language::Russian))
    }

    fn get_shellenv() -> ShellProps {
        ShellProps {
            hostname: String::from("default"),
            username: String::from("user"),
            elapsed_time: Duration::from_secs(0),
            exit_status: 0,
            wrkdir: PathBuf::from("/home/user/")
        }
    }
}