azure-sdk-for-cpp/sdk/storage/azure-storage-common/sample/main.cpp
JinmingHu 3a4e1f3b49
Restructure storage directory (#536)
* Restructure azure storage directory

* Add tests and sample

* reformat with clang-format

* Reorder files in CMake

* load versions from version.txt

* fix crash

* Update README.md

* Use relative links

* fix CI

* Fix CI

* Try to fix CI

* Move option to the top of the file
2020-08-27 16:16:08 +08:00

66 lines
1.3 KiB
C++

// Copyright(c) Microsoft Corporation.All rights reserved.
// SPDX - License - Identifier : MIT
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstdio>
#include <stdexcept>
#include "samples_common.hpp"
const std::string& GetConnectionString()
{
const static std::string c_ConnectionString = "";
if (!c_ConnectionString.empty())
{
return c_ConnectionString;
}
const static std::string envConnectionString = std::getenv("AZURE_STORAGE_CONNECTION_STRING");
if (!envConnectionString.empty())
{
return envConnectionString;
}
throw std::runtime_error("Cannot find connection string");
}
int main(int argc, char** argv)
{
if (argc != 2)
{
printf("Usage: %s <sample name>\n", argv[0]);
}
else if (std::string(argv[1]) == "All")
{
for (auto sample : Sample::samples())
{
auto func = sample.second;
func();
}
return 0;
}
else
{
auto ite = Sample::samples().find(argv[1]);
if (ite == Sample::samples().end())
{
printf("Cannot find sample %s\n", argv[1]);
}
else
{
auto func = ite->second;
func();
return 0;
}
}
printf("\nAvailable sample names:\n All\n");
for (const auto& i : Sample::samples())
{
printf(" %s\n", i.first.data());
}
return 1;
}