Commit Graph

326 Commits

Author SHA1 Message Date
Matthias Beyer 83aa5afcbe Build ModuleError out of StorageBackendError if any 2015-12-02 12:24:05 +01:00
Matthias Beyer c3019528cf ModuleError needs a cause as well 2015-12-02 12:24:05 +01:00
Matthias Beyer 4a6d1a74c0 Retry fixing the StorageBackend::cause() 2015-12-02 12:24:05 +01:00
Matthias Beyer 366121b6ed Reimplement StorageBackend::update_file() 2015-12-02 12:24:05 +01:00
Matthias Beyer eabf726846 Outsource file to string parsing 2015-12-02 12:24:05 +01:00
Matthias Beyer e0fefc3da4 Reimplement StorageBackend::put_file() 2015-12-02 12:24:05 +01:00
Matthias Beyer 21d889e1e2 Add caused_by field in StorageBackend 2015-12-02 12:24:05 +01:00
Matthias Beyer 455d6e88ed Use real array instead of text array to save tags 2015-12-02 12:24:05 +01:00
Matthias Beyer cf1687e8ba Convention: module names are lowercase 2015-12-02 12:24:05 +01:00
Matthias Beyer 1038880de9 Save storepath in extra variable 2015-12-02 12:24:05 +01:00
Matthias Beyer 8a2c41ea22 Fix: Build StorageBackend with runtime 2015-12-02 12:24:05 +01:00
Matthias Beyer e78bde72c1 Implement add_command() with backend 2015-12-02 12:24:05 +01:00
Matthias Beyer c9ebe3b7a1 Pass owner to file path builder helper function 2015-12-02 12:24:05 +01:00
Matthias Beyer 98ec735ea3 Add File::owner() - a getter for the owner of a file 2015-12-02 12:24:05 +01:00
Matthias Beyer 593e98ac5d A File is bound to a Module
A File object must be bound to a Module, as one Module owns the File.

This way we can use the Module internally to build the file path later.
2015-12-02 12:24:05 +01:00
Matthias Beyer 0d751f9ffd Add some debug output in StorageBackend::build_filepath_with_id() 2015-12-02 12:24:05 +01:00
Matthias Beyer 7531b5a6d7 Pass module to subcommand.
We need the module in the subcommand for building file paths and so on.

To be able to pass it, we must remove the ::new() function from the
trait, so we can make the parameter a trait object.

This is no object, as the module gets build non-generically from the
main(), so everything is fine with this.
2015-12-02 12:24:05 +01:00
Matthias Beyer ff873c8fe3 Transfer old code to new structure 2015-12-02 12:24:05 +01:00
Matthias Beyer 08d6e8da13 We need to unwrap here (and it is save) 2015-12-02 12:24:05 +01:00
Matthias Beyer fda2c4feea Add CommandEnv building in command calling code in main() 2015-12-02 12:24:05 +01:00
Matthias Beyer 0a026002b0 Pass CommandEnv struct to command exec function
So we can add parameters rather easily.
Also define CommandResult as result type.
2015-12-02 12:24:05 +01:00
Matthias Beyer 9bf9f96ab1 Fix: ModuleError::mk() -> pub ModuleError::new() 2015-12-02 12:24:05 +01:00
Matthias Beyer 18ea01b854 Pass StorageBackend to subcommand function 2015-12-02 12:24:05 +01:00
Matthias Beyer 3f19aba7b2 Add subcommand calling code in main() 2015-12-02 12:24:05 +01:00
Matthias Beyer 4a73a317d4 Move submodule commands/mod.rs to commands.rs 2015-12-02 12:24:05 +01:00
Matthias Beyer e10d1bcb65 Reimplement commands for bm 2015-12-02 12:24:05 +01:00
Matthias Beyer 24a6e961af Change get_commands() for latest trait change 2015-12-02 12:24:05 +01:00
Matthias Beyer 8af9ba48c0 We dont need the command traits anymore 2015-12-02 12:24:05 +01:00
Matthias Beyer 84571bef0a get_commands() can return a HashMap<str, fn()>, which is command name -> command function 2015-12-02 12:24:05 +01:00
Matthias Beyer a24d3175dd We do not have Module::execute() anymore 2015-12-02 12:24:05 +01:00
Matthias Beyer 8404303dbd Remove BMModule::execute() which is not required by the trait anymore 2015-12-02 12:24:05 +01:00
Matthias Beyer 168852714a Add modules for commands of BM module 2015-12-02 12:24:05 +01:00
Matthias Beyer 55361f71fe Add struct for passing environment of command to command execute function 2015-12-02 12:24:05 +01:00
Matthias Beyer a9a33321f7 Make command submodule public 2015-12-02 12:24:05 +01:00
Matthias Beyer f94f8870e9 The exec() function of an ExecutableCommand should get the CLI matches as well 2015-12-02 12:24:05 +01:00
Matthias Beyer 4af971a5d0 Make these types public 2015-12-02 12:24:05 +01:00
Matthias Beyer cbd85b3d8e Module should only provide functionality to get a list of commands it can execute
These commands can then be executed.
2015-12-02 12:24:05 +01:00
Matthias Beyer 86286cce1b Remove livetimes 2015-12-02 12:24:05 +01:00
Matthias Beyer bfccbc32c5 Add BMModule::add() implementation 2015-12-02 12:24:05 +01:00
Matthias Beyer 0896f2093b Fixed inverted logic in get_tags() 2015-12-02 12:24:05 +01:00
Matthias Beyer 006724a184 Refactor get_tags to return no Option 2015-12-02 12:24:05 +01:00
Matthias Beyer 51f6af6346 We should really use String here 2015-12-02 12:24:05 +01:00
Matthias Beyer cd72295c1a Add function to build header content 2015-12-02 12:24:05 +01:00
Matthias Beyer 9f29f0e1b7 Reject tasks if they contain spaces 2015-12-02 12:24:05 +01:00
Matthias Beyer 8cffdddab2 Split header spec into smaller functions 2015-12-02 12:24:05 +01:00
Matthias Beyer b76d38f4c6 Rewrite Bookmark FileHeaderSpec
One file is one bookmark, so we should have the appropriate header spec
for this.
2015-12-02 12:24:05 +01:00
Matthias Beyer 07f223bb8a Add header module with spec 2015-12-02 12:24:05 +01:00
Matthias Beyer de843541f1 Add some debugging output in bm module 2015-12-02 12:24:05 +01:00
Matthias Beyer 15a2480604 Add information on what gets done 2015-12-02 12:24:05 +01:00
Matthias Beyer 750f4cd31c Start adding the BM submodule 2015-12-02 12:24:05 +01:00
Matthias Beyer efe1577f02 TablePrinter should be pub 2015-12-02 12:20:54 +01:00
Matthias Beyer c3397d5238 Use prettytable to implement TablePrinter 2015-12-02 12:20:52 +01:00
Matthias Beyer 918016368e Add file printer helpers 2015-12-02 12:20:23 +01:00
Matthias Beyer 2bab3d48e6 Fix JsonHeaderParser::serialize() 2015-12-02 12:00:20 +01:00
Matthias Beyer 7549db4ffc Fix JsonHeaderParser::visit_json() 2015-12-02 12:00:20 +01:00
Matthias Beyer 500fb281a0 JsonHeaderParser: Make spec optional 2015-12-02 12:00:20 +01:00
Matthias Beyer 34cf5076f9 Reimplement JsonHeaderParser::write() 2015-12-02 12:00:19 +01:00
Matthias Beyer df18071d9a Move JsonHeaderParser::new() out of trait implementation 2015-12-02 12:00:19 +01:00
Matthias Beyer cf196b2492 Fixup: get_file_ids() - use prefix_of_files_for_module() 2015-12-02 12:00:19 +01:00
Matthias Beyer 0e4a56fe68 Reimplement StorageBackend::new(), create directory if not existing, store storepath in extra variable 2015-12-02 12:00:19 +01:00
Matthias Beyer 1e5c50bc0b Fixup: Import remove_file() 2015-12-02 12:00:19 +01:00
Matthias Beyer 0796d0ab36 Fixup: File::from_parser_result() gets module now as well 2015-12-02 12:00:19 +01:00
Matthias Beyer 9a0cc75c6f BackendOperationResult: Add optional type parameter 2015-12-02 12:00:19 +01:00
Matthias Beyer d35e89f27c Fixup: get_file_by_id() gets &Module as well, so it can use build_filepath_with_id() 2015-12-02 12:00:19 +01:00
Matthias Beyer c81800d985 Implement helpers: build_filepath_with_id(), prefix_of_files_for_module() 2015-12-02 12:00:19 +01:00
Matthias Beyer 0363075f9c Implement StorageBackend::remove_file() 2015-12-02 12:00:19 +01:00
Matthias Beyer c23a1e22ab Implement helper write_with_parser() 2015-12-02 12:00:19 +01:00
Matthias Beyer 25b26b03a6 Reimplement StorageBackend::update_file() 2015-12-02 12:00:19 +01:00
Matthias Beyer 8bd782c1a7 Reimplement StorageBackend::put_file() 2015-12-02 12:00:19 +01:00
Matthias Beyer d141a3670f Add StorageBackend::iter_files() 2015-12-02 12:00:19 +01:00
Matthias Beyer 1b6711fe10 Add StorageBackend::iter_ids() 2015-12-02 12:00:19 +01:00
Matthias Beyer d22b991da0 Implement StorageBackendError::build() helper 2015-12-02 12:00:19 +01:00
Matthias Beyer 8ff5dcc9e8 Add StorageBackendError::caused_by member 2015-12-02 12:00:19 +01:00
Matthias Beyer c73cb88df4 Remove StorageBackendError::explanation member 2015-12-02 12:00:19 +01:00
Matthias Beyer 9493c79104 Reimplement Debug for File 2015-12-02 12:00:12 +01:00
Matthias Beyer 535952c2a5 Implement Display for File 2015-12-02 11:58:07 +01:00
Matthias Beyer 6eb7bee355 Reimplement File::contents() with File::{header(),data()} 2015-12-02 11:58:07 +01:00
Matthias Beyer 09940f3228 Each file must have an owning module 2015-12-02 11:58:07 +01:00
Matthias Beyer 90f08cc1f2 Implement File::{header(),data()} as header/data getters 2015-12-02 11:32:59 +01:00
Matthias Beyer d89977a09e Implement File::matches_with(&Regex) 2015-12-02 11:32:14 +01:00
Matthias Beyer 58bd36599f Implement FileHeaderData::matches_with(&Regex) 2015-12-02 11:30:50 +01:00
Matthias Beyer 8f8badebb3 Fix: FileHeaderData::Key::name must be a &'static str 2015-12-02 11:30:14 +01:00
Matthias Beyer 2a468059aa parser: Remove livetimes 2015-12-02 11:28:21 +01:00
Matthias Beyer a5dabe55a9 Provide getter for store path in Runtime object 2015-12-01 18:37:44 +01:00
Matthias Beyer 5942877c43 Add possibility to override store name in CLI 2015-12-01 18:37:29 +01:00
Matthias Beyer da85c3ffe7 Rename function: store_path_str() -> store_path() 2015-12-01 18:36:04 +01:00
Matthias Beyer 5f4718a2e5 Add debug output for Configuration::new() 2015-12-01 18:32:00 +01:00
Matthias Beyer 56cd6dc4ae Configuration::new() should use default values
if the configuration can not be loaded.
2015-12-01 18:25:29 +01:00
Matthias Beyer 9edad2800f Add debugging output in storage parser code 2015-11-27 22:18:26 +01:00
Matthias Beyer 53a14ea1dc Add debug output in storage backend code 2015-11-27 22:14:02 +01:00
Matthias Beyer 20dc562dee Do debug output when creating a file object 2015-11-27 19:37:20 +01:00
Matthias Beyer c82f9ea6ae Implement Debug for File 2015-11-27 19:37:08 +01:00
Matthias Beyer 55d6de627a Add debug output in match_header_spec() 2015-11-27 19:31:46 +01:00
Matthias Beyer beee7b20b4 Add debug output in main 2015-11-27 19:24:58 +01:00
Matthias Beyer beccb7ab3d Implement Debug for Configuration 2015-11-27 19:22:21 +01:00
Matthias Beyer a487fbcaf4 Implement Debug for CliConfig 2015-11-27 19:22:09 +01:00
Matthias Beyer 990252e4e4 Implement Debug for Runtime 2015-11-27 19:22:09 +01:00
Matthias Beyer 469ff607eb Fix: unused import 2015-11-27 17:00:45 +01:00
Matthias Beyer 06ea949e65 Fix: unused import 2015-11-27 17:00:34 +01:00
Matthias Beyer 869cc5e5ab Fix: unused import 2015-11-27 16:59:51 +01:00
Matthias Beyer 56612cf1a0 Fix: unused import 2015-11-27 16:59:44 +01:00
Matthias Beyer 7786eed7f0 Fix: unused import 2015-11-27 16:59:05 +01:00
Matthias Beyer 82e346e89b Fix: unused import 2015-11-27 16:58:38 +01:00
Matthias Beyer 5bd40d208a Fix: unused import 2015-11-27 16:58:19 +01:00
Matthias Beyer e8af265c0c Fix: unused import 2015-11-27 16:57:52 +01:00
Matthias Beyer 6926363f70 Fix: use unimplemented instead of false implementation 2015-11-27 16:55:18 +01:00
Matthias Beyer 8a546dfb26 Fix Bug: Pass iterator value, not currently parsed value 2015-11-27 16:52:09 +01:00
Matthias Beyer 3ed431ad5f Fix: unnecessary parentheses around `if` condition 2015-11-27 16:50:54 +01:00
Matthias Beyer 930a7ecc3f Fix: structure field `dataDump` should have a snake case name such as `data_dump` 2015-11-27 16:50:12 +01:00
Matthias Beyer c8231e5c31 Fix: variable does not need to be mutable 2015-11-27 16:49:25 +01:00
Matthias Beyer c597f6d1f0 Fix compiletime errors 2015-11-24 19:37:22 +01:00
Matthias Beyer a6054d2223 StorageBackendError: Use String instead of str in params 2015-11-24 19:31:22 +01:00
Matthias Beyer f694feacf9 Clone these values when returning them 2015-11-24 19:28:26 +01:00
Matthias Beyer a8bc7ecc47 Make FileHeaderData cloneable 2015-11-24 19:27:57 +01:00
Matthias Beyer 2ed2b17b85 Refactor get_file_by_id() into smaller functions 2015-11-24 16:47:01 +01:00
Matthias Beyer 1b1f0678cb Refactor: File::from_parser_result() shouldnt do error handling, do this in calling code 2015-11-24 16:34:03 +01:00
Matthias Beyer b6af948c0e Implement Storage::get_file_by_id() 2015-11-24 10:59:30 +01:00
Matthias Beyer 176183e718 Refactor helpers for more fine-grained possibilities 2015-11-24 10:59:16 +01:00
Matthias Beyer 4464c32b98 Add helper to build file from Parser return value 2015-11-24 10:58:54 +01:00
Matthias Beyer 8808e911c8 Implement Storage::update_file() 2015-11-24 10:48:30 +01:00
Matthias Beyer 14ae6d623b Refactor: Outsource filepath building 2015-11-24 10:30:52 +01:00
Matthias Beyer f498ffa54c Implement Storage::put_file() 2015-11-24 10:27:42 +01:00
Matthias Beyer 616e0b789b Make Parser::write() public 2015-11-24 10:27:34 +01:00
Matthias Beyer c2135b5c6c Add getter methods for File object contents 2015-11-24 10:27:20 +01:00
Matthias Beyer da792694c5 Add StorageBackend builder 2015-11-23 19:54:08 +01:00
Matthias Beyer e1faad7a28 Add runtime rtp getter (and in cli and configuration types) 2015-11-23 19:48:37 +01:00
Matthias Beyer 14d92d8b2f Add some functions to File, so we can generate file instances with content 2015-11-23 19:27:54 +01:00
Matthias Beyer 91de245836 Rename function to match naming scheme 2015-11-23 19:26:02 +01:00
Matthias Beyer b8fa7c5696 Reset and restart implementation 2015-11-23 19:25:27 +01:00
Matthias Beyer e623b74139 Implement: Storage::createFile() 2015-11-23 19:17:46 +01:00
Matthias Beyer 263a3b7780 Store the file handle in our internal File type 2015-11-23 19:17:46 +01:00
Matthias Beyer 7faa693d5c Move implementation to get a new file on the FS
Now we have a function which creates a new file on the FS and returns
the handle and the FileID object.
2015-11-23 19:17:46 +01:00
Matthias Beyer 48fd3e66f5 Add implementation for Storage::createEmpty() 2015-11-23 19:17:46 +01:00
Matthias Beyer 25de1c6c2a We should use the FileID type in the File 2015-11-23 18:46:09 +01:00
Matthias Beyer bff2bf68c6 We dont need to pass the module here 2015-11-23 18:45:31 +01:00
Matthias Beyer 9aced858ac Outsource file id parsing 2015-11-23 18:42:55 +01:00
Matthias Beyer b0e5f28528 Implement getFileList() 2015-11-23 18:28:24 +01:00
Matthias Beyer 68c6c35f54 Add getFileList(self) to list files from basepath 2015-11-20 15:34:40 +01:00
Matthias Beyer 2af5f404f4 Fix typo in StorageBackend::new() 2015-11-20 15:34:06 +01:00
Matthias Beyer 7e86394b3c add dep: glob 2015-11-20 15:33:40 +01:00
Matthias Beyer e59fbd52c3 Add fn to extract id from path string 2015-11-20 15:33:24 +01:00
Matthias Beyer 42ac04c1a8 Implement StorageBackend::new() 2015-11-10 20:53:35 +01:00
Matthias Beyer 9cff6772c8 Implement StorageBackendError 2015-11-10 20:43:55 +01:00
Matthias Beyer 99a2670803 Add module/command trait 2015-11-10 20:43:53 +01:00
Matthias Beyer ba91e7ee26 The module itself has to be populate the Command instance
This will be done by the module returning a lambda to build the
command instance.
2015-11-10 20:43:35 +01:00
Matthias Beyer f4dbec72ee Add storage/backend setup 2015-11-10 20:43:30 +01:00
Matthias Beyer e73701ace4 Remove old todo module code 2015-11-10 20:33:47 +01:00
Matthias Beyer 159b363d58 Remove the concept of DataParser and Abstract Data types
We use String as type for Data, so we don't have problems with parsing
things and the whole templating foo in the parser gets a lot simpler.
2015-11-10 20:31:05 +01:00
Matthias Beyer e3afb3c0f3 Implement Serialization for FileHeaderData 2015-11-09 18:35:07 +01:00
Matthias Beyer 9167fde4fb Add dependency: serde 2015-11-09 18:35:07 +01:00