1 /** 2 * Copyright 2020 Huawei Technologies Co., Ltd 3 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 8 * http://www.apache.org/licenses/LICENSE-2.0 9 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #include <iostream> 17 #include "minddata/dataset/engine/cache/cache_admin_arg.h" 18 #include "minddata/dataset/engine/cache/cache_common.h" 19 #include "minddata/dataset/util/path.h" 20 #include "mindspore/core/utils/log_adapter.h" 21 22 namespace ms = mindspore; 23 namespace ds = mindspore::dataset; 24 main(int argc,char ** argv)25int main(int argc, char **argv) { 26 ms::Status rc; 27 ds::CacheAdminArgHandler args; 28 std::stringstream arg_stream; 29 // Create the common path for all users 30 ds::Path common_dir = ds::Path(ds::kDefaultCommonPath); 31 rc = common_dir.CreateCommonDirectories(); 32 if (rc.IsError()) { 33 std::cerr << rc.ToString() << std::endl; 34 return 1; 35 } 36 37 #ifdef USE_GLOG 38 #define google mindspore_private 39 FLAGS_logtostderr = false; 40 FLAGS_log_dir = ds::DefaultLogDir(); 41 // Create default log dir 42 ds::Path log_dir = ds::Path(FLAGS_log_dir); 43 rc = log_dir.CreateDirectories(); 44 if (rc.IsError()) { 45 std::cerr << rc.ToString() << std::endl; 46 return 1; 47 } 48 google::InitGoogleLogging(argv[0]); 49 #undef google 50 #endif 51 52 if (argc == 1) { 53 args.Help(); 54 return 1; 55 } 56 57 // ingest all the args into a string stream for parsing 58 for (int i = 1; i < argc; ++i) { 59 arg_stream << " " << std::string(argv[i]); 60 } 61 62 // Parse the args 63 rc = args.ParseArgStream(&arg_stream); 64 if (!rc.IsOk()) { 65 std::cerr << rc.ToString() << std::endl; 66 return 1; 67 } 68 69 // Execute the command 70 rc = args.RunCommand(); 71 if (!rc.IsOk()) { 72 std::cerr << rc.ToString() << std::endl; 73 return 1; 74 } 75 76 return 0; 77 } 78