-
Notifications
You must be signed in to change notification settings - Fork 319
CLI and feedback enhancements #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
ecae36e
8be2c0c
76b3658
5dfe40d
2278318
084d9c6
ca0bd59
95c50a8
e0b6c2a
a177e4f
0d1cb02
7e74061
1274c94
6a952e3
a3497a3
5263452
ac94a69
f5c13b3
5ca8c1d
fed38ca
f141786
8f25328
59b35cc
ddc5711
a09392a
14fc152
3814eb7
72a2d64
86333a1
8f3c267
13be3fd
4b5ee62
475094a
01b4cc5
0ce28db
5a896d8
92f36e0
c28b210
02adbde
1a625af
d204d3e
66ca610
41b5a0f
b3d8e49
09ebe46
365245d
07be979
6e20cd0
351a7d4
ea55180
ff06c06
d13ff30
768fe14
7677f1c
79b71a9
abf7afe
6b96848
f2c7665
6301a02
e3bb107
7c2267a
b33cb3a
ce842bd
d927efd
cf923d2
1873091
93455d6
e995657
94dc3db
942a688
b37e464
6787ab1
793d446
6189051
366f82e
843ab5c
f5bada6
5e96528
5bf8d75
23d40e8
36829cb
27aca3b
3fab0be
d2ee494
647c156
615fb62
2a47358
3047e6a
7323702
0f5c691
7af2439
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,4 +14,5 @@ CMakeCache.txt | |
| *.clst | ||
| *.snap | ||
| node_modules | ||
| build | ||
| build | ||
| bin/ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ static map<string, shared_ptr<FileBuffer>> g_filebuffer_map; | |
| static mutex g_mutex_map; | ||
| static bool g_small_memory = true; | ||
|
|
||
| // [what is the point/value of this value?] | ||
| #define MAGIC_PATH '>' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mark avoid dead loop when search parent path |
||
|
|
||
| string g_current_dir = ">"; | ||
|
|
@@ -127,6 +128,9 @@ int DataBuffer::ref_other_buffer(std::shared_ptr<FileBuffer> p, size_t offset, s | |
| return 0; | ||
| }; | ||
|
|
||
| /** | ||
| * @brie Base class for FS things [whatever 'FS' means/is]. | ||
| */ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove [...] |
||
| class FSBasic | ||
| { | ||
| public: | ||
|
|
@@ -142,55 +146,86 @@ class FSBasic | |
| virtual std::shared_ptr<FragmentBlock> ScanCompressblock(const string& /*backfile*/, size_t& /*input_offset*/, size_t& /*output_offset*/) { return NULL; }; | ||
| virtual int PreloadWorkThread(shared_ptr<FileBuffer>outp); | ||
|
|
||
| virtual int split(const string &filename, string *outbackfile, string *outfilename, bool dir=false) | ||
| { | ||
| string path = str_to_upper(filename); | ||
| /** | ||
| * @brief Splits a file system path into directory and final name parts | ||
| * @param path Input path | ||
| * @param[out] dir_part Directory path info from input path | ||
| * @param[out] name_part Final name part from input path | ||
| * @param dir [what does this mean/imply?] | ||
| * @return 0 for success; -1 for error | ||
| * @details | ||
| * If no/blank m_ext: | ||
| * If dir: | ||
| * Load dir_part with directory path part of path; >./ if none | ||
| * Load name_part with file name part of path; blank if none | ||
| * Else: | ||
| * Load dir_part with input path | ||
| * Else: | ||
| * ext = m_ext | ||
| * Append slash to ext if !dir | ||
| * Find last ext in path | ||
| * If not found: fail | ||
| * Load dir_part with path up to and including ext | ||
| * Load name_part with path after found ext | ||
| * @example | ||
| * path:"f", m_ext:"", !dir ==> ">./", "f" | ||
| * path:"d/f", m_ext:"", !dir ==> "d", "f" | ||
| * path:"d/", m_ext:"", !dir ==> "d", "" | ||
| * path:"f", m_ext:"z", !dir ==> error | ||
| * path:"d/z/f", m_ext:"z", !dir ==> "d/z", "f" | ||
| * path:"d/z/", m_ext:"z", !dir ==> "d/z", "" | ||
| * @note | ||
| * Passing a bool like dir is bad style since it only controls flow. | ||
| */ | ||
| virtual int split(const string &path, string *dir_part, string *name_part, bool dir=false) | ||
| { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use seperate patch to change outbackfile-> dir_part, outfilename -> filename_part |
||
| string upper_path = str_to_upper(path); | ||
| if (m_ext == nullptr || strlen(m_ext) == 0) | ||
| { | ||
| if(dir) | ||
| { | ||
| size_t pos = path.rfind("/"); | ||
| size_t pos = upper_path.rfind("/"); | ||
| if(pos == string::npos) | ||
| { | ||
| *outbackfile = MAGIC_PATH; | ||
| *outbackfile += "./"; | ||
| *outfilename = filename; | ||
| *dir_part = MAGIC_PATH; | ||
| *dir_part += "./"; | ||
| *name_part = path; | ||
| } else { | ||
| *outbackfile = filename.substr(0, pos); | ||
| if(filename.size() >= pos + 1) | ||
| *outfilename = filename.substr(pos + 1); | ||
| *dir_part = path.substr(0, pos); | ||
| if(path.size() >= pos + 1) | ||
| *name_part = path.substr(pos + 1); | ||
| else | ||
| outfilename->clear(); | ||
| name_part->clear(); | ||
| } | ||
| }else | ||
| { | ||
| *outbackfile = filename; | ||
| *dir_part = path; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| string ext = m_ext; | ||
| if(!dir) | ||
| ext += "/"; | ||
| size_t pos = path.rfind(ext); | ||
| size_t pos = upper_path.rfind(ext); | ||
| if (pos == string::npos) | ||
| { | ||
| string err = "can't find ext name in path: "; | ||
| err += filename; | ||
| string err = "Expected '" + ext + "' in path '" + path + "'"; | ||
| set_last_err_string(err); | ||
| return -1; | ||
| } | ||
|
|
||
| *outbackfile = filename.substr(0, pos + strlen(m_ext)); | ||
| *dir_part = path.substr(0, pos + strlen(m_ext)); | ||
|
|
||
| if(filename.size() >= pos + strlen(m_ext) + 1) | ||
| *outfilename = filename.substr(pos + strlen(m_ext) + 1); | ||
| if(path.size() >= pos + strlen(m_ext) + 1) | ||
| *name_part = path.substr(pos + strlen(m_ext) + 1); | ||
| else | ||
| outfilename->clear(); | ||
| name_part->clear(); | ||
| return 0; | ||
| } | ||
|
|
||
| protected: | ||
| FSBasic() {} // enforce that this class is abstract base; only creatable via a superclass | ||
| const char * m_ext = nullptr; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one should be sperate patch |
||
| const char * m_Prefix = nullptr; | ||
| public: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -570,12 +570,12 @@ int FBFlashCmd::parser(char *p) | |
| } | ||
|
|
||
| if (!check_file_exist(m_filename)) { | ||
| set_last_err_string("FB: image file not found"); | ||
| set_last_err_string("FB: image file not found: " + m_filename); | ||
| return -1; | ||
| } | ||
|
|
||
| if (m_use_bmap && m_bmap_filename.size() && !check_file_exist(m_bmap_filename)) { | ||
| set_last_err_string("FB: bmap file not found"); | ||
| set_last_err_string("FB: bmap file not found: " + m_bmap_filename); | ||
| return -1; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid two line should sperate patch, show improve error message |
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -574,7 +574,7 @@ int CmdUsbCtx::look_for_match_device(const char *pro) | |
|
|
||
| uuu_notify nt; | ||
| nt.type = nt.NOTIFY_WAIT_FOR; | ||
| nt.str = (char*)"Wait for Known USB"; | ||
| nt.str = (char*)"DWait for Known USB"; | ||
| call_notify(nt); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need 'D' |
||
|
|
||
| if (check_usb_timeout(usb_timer)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,28 +203,21 @@ int auto_complete(int argc, char**argv) | |
|
|
||
| void print_autocomplete_help() | ||
| { | ||
|
|
||
| cout << "\nEnable auto/tab completion:" << endl << endl; | ||
| #ifndef _MSC_VER | ||
| { | ||
| cout << "Enjoy auto [tab] command complete by put below script into /etc/bash_completion.d/uuu" << endl; | ||
| cout << g_vt_kcyn; | ||
| cout << " _uuu_autocomplete()" <<endl; | ||
| cout << " {" << endl; | ||
| cout << " COMPREPLY=($(" << TARGET_PATH << " $1 $2 $3))" << endl; | ||
| cout << " }" << endl; | ||
| cout << " complete -o nospace -F _uuu_autocomplete uuu" << g_vt_default << endl << endl; | ||
| } | ||
| cout << "Bash: Put the following script into /etc/bash_completion.d/uuu" << endl; | ||
| cout << g_vt_kcyn; | ||
| cout << " _uuu_autocomplete()" <<endl; | ||
| cout << " {" << endl; | ||
| cout << " COMPREPLY=($(" << TARGET_PATH << " $1 $2 $3))" << endl; | ||
| cout << " }" << endl; | ||
| cout << " complete -o nospace -F _uuu_autocomplete uuu" << g_vt_default << endl << endl; | ||
| #else | ||
| { | ||
| printf("Powershell: Enjoy auto [tab] command complete by run below command or put into Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1\n"); | ||
|
|
||
| HMODULE hModule = GetModuleHandleA(NULL); | ||
| char path[MAX_PATH]; | ||
| GetModuleFileNameA(hModule, path, MAX_PATH); | ||
|
|
||
| printf(" Register-ArgumentCompleter -CommandName uuu -ScriptBlock {param($commandName,$parameterName,$wordToComplete,$commandAst,$fakeBoundParameter); %s -autocomplete $parameterName }\n\n", | ||
| path); | ||
| } | ||
| HMODULE hModule = GetModuleHandleA(NULL); | ||
| char path[MAX_PATH]; | ||
| GetModuleFileNameA(hModule, path, MAX_PATH); | ||
| cout << | ||
| "PowerShell: run the following command or put in Documents\\WindowsPowerShell\\Microsoft.PowerShell_profile.ps1" << endl << | ||
| "\tRegister-ArgumentCompleter -CommandName uuu -ScriptBlock {param($commandName,$parameterName,$wordToComplete,$commandAst,$fakeBoundParameter); " << path << " -autocomplete $parameterName }" << endl; | ||
| #endif | ||
|
|
||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this part should be sperate patch |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -225,7 +225,7 @@ void BuiltInScriptMap::ShowAll() const | |
| */ | ||
| void BuiltInScriptMap::ShowCmds(FILE * const file) const | ||
| { | ||
| fprintf(file, "<"); | ||
| //fprintf(file, "<"); | ||
| for (auto iCol = begin(); iCol != end(); ++iCol) | ||
| { | ||
| fprintf(file, "%s", iCol->first.c_str()); | ||
|
|
@@ -237,7 +237,7 @@ void BuiltInScriptMap::ShowCmds(FILE * const file) const | |
| fprintf(file, "|"); | ||
| } | ||
| } | ||
| fprintf(file, ">"); | ||
| //fprintf(file, ">"); | ||
| } | ||
|
||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create sperate patch for .gitignore file