File tree 5 files changed +25
-22
lines changed
Filter options
5 files changed +25
-22
lines changed
Original file line number Diff line number Diff line change 3
3
//
4
4
5
5
#include " cli_args.h"
6
+ #include " ../utils/string_formatting/string_coloring.h"
6
7
#include < string>
8
+ #include < iostream>
9
+ #include < vector>
10
+ #include < filesystem>
11
+ namespace fs = std::filesystem;
7
12
8
- std::string parse_args () {
9
- return " hello args" ;
10
- }
13
+ std::string parse_args (int argc, char * argv[]) {
14
+ std::cout << argc << std::endl;
15
+ if (argc <= 1 ) return " ." ;
16
+ return " /Users/willlane/dev/nat" ;
17
+ }
Original file line number Diff line number Diff line change 6
6
#define NATCPP_CLI_ARGS_H
7
7
#include < string>
8
8
9
- std::string parse_args ();
9
+ std::string parse_args (int , char ** );
10
10
11
11
#endif // NATCPP_CLI_ARGS_H
Original file line number Diff line number Diff line change 2
2
// Created by Will Lane on 2/2/21.
3
3
//
4
4
5
- // #include <filesystem>
6
- // #include <vector>
7
- #include < iostream>
8
- #include < string>
9
5
#include " args/cli_args.h"
10
6
#include " utils/types.h"
11
- #include " utils/fs/handle_files.h"
12
- namespace fs = std::filesystem;
13
7
14
8
int main (int argc, char * argv[]) {
15
- auto args = parse_args ();
16
- auto f = get_files (" ." );
17
-
18
- auto dir = new Directory (" ." );
19
- for (File file : dir->get_paths ()) {
20
- std::cout << file.get_perms () << ' ' ;
21
- std::cout << file.get_size () << ' ' ;
22
- std::cout << file.get_group () << ' ' ;
23
- std::cout << file.get_user () << ' ' ;
24
- std::cout << file.get_modified () << ' ' ;
25
- std::cout << file.get_path ().path () << std::endl;
26
- }
9
+ (new Directory (parse_args (argc, argv)))->show_ls ();
27
10
28
11
return 0 ;
29
12
}
Original file line number Diff line number Diff line change 14
14
#include < pwd.h>
15
15
#include < chrono>
16
16
#include < sstream>
17
+ #include < iostream>
17
18
namespace fs = std::filesystem;
18
19
19
20
File :: File (
@@ -152,3 +153,14 @@ Directory :: Directory (const std::string& path) {
152
153
std::vector<File> Directory :: get_paths() {
153
154
return this ->paths ;
154
155
}
156
+
157
+ void Directory :: show_ls() {
158
+ for (File file : this ->get_paths ()) {
159
+ std::cout << file.get_perms () << ' ' ;
160
+ std::cout << file.get_size () << ' ' ;
161
+ std::cout << file.get_group () << ' ' ;
162
+ std::cout << file.get_user () << ' ' ;
163
+ std::cout << file.get_modified () << ' ' ;
164
+ std::cout << file.get_path ().path () << std::endl;
165
+ }
166
+ }
Original file line number Diff line number Diff line change @@ -80,5 +80,6 @@ class Directory {
80
80
~Directory () = default ;
81
81
82
82
std::vector<File> get_paths ();
83
+ void show_ls ();
83
84
};
84
85
#endif // NATCPP_TYPES_H
You can’t perform that action at this time.
0 commit comments