Skip to content

Commit

Permalink
Add: Implemented 'init' command
Browse files Browse the repository at this point in the history
  • Loading branch information
muqiuhan committed Aug 29, 2023
1 parent c86118e commit 29e61ab
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 76 deletions.
13 changes: 7 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(CMAKE_C_COMPILER "/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
add_executable(bonding "")
set_target_properties(bonding PROPERTIES OUTPUT_NAME "bonding")
set_target_properties(bonding PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/linux/x86_64/debug")
set_target_properties(bonding PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/build/linux/x86_64/release")
target_include_directories(bonding PRIVATE
/home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
)
Expand All @@ -24,18 +24,19 @@ target_compile_definitions(bonding PRIVATE
target_compile_options(bonding PRIVATE
$<$<COMPILE_LANGUAGE:C>:-m64>
$<$<COMPILE_LANGUAGE:CXX>:-m64>
$<$<COMPILE_LANGUAGE:C>:-DNDEBUG>
$<$<COMPILE_LANGUAGE:CXX>:-DNDEBUG>
)
set_target_properties(bonding PROPERTIES CXX_EXTENSIONS OFF)
target_compile_features(bonding PRIVATE cxx_std_17)
if(MSVC)
target_compile_options(bonding PRIVATE $<$<CONFIG:Debug>:-Od>)
target_compile_options(bonding PRIVATE $<$<CONFIG:Release>:-Ox -fp:fast>)
else()
target_compile_options(bonding PRIVATE -O0)
target_compile_options(bonding PRIVATE -O3)
endif()
if(MSVC)
target_compile_options(bonding PRIVATE -Zi)
else()
target_compile_options(bonding PRIVATE -g)
target_compile_options(bonding PRIVATE -fvisibility=hidden)
endif()
if(MSVC)
set_property(TARGET bonding PROPERTY
Expand Down Expand Up @@ -69,8 +70,8 @@ target_sources(bonding PRIVATE
src/error.cpp
src/mount.cpp
src/namespace.cpp
src/resource.cpp
src/syscall.cpp
src/unix.cpp
src/resource.cpp
)

104 changes: 52 additions & 52 deletions build.ninja
Original file line number Diff line number Diff line change
Expand Up @@ -9,49 +9,49 @@ rule gen
description = regenerating ninja files

# rules for compiler
rule as
rule cc
command = /usr/bin/ccache /usr/bin/clang $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = ccache compiling.debug $in
description = ccache compiling.release $in

rule mm
rule as
command = /usr/bin/ccache /usr/bin/clang $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = ccache compiling.debug $in
description = ccache compiling.release $in

rule mxx
rule mm
command = /usr/bin/ccache /usr/bin/clang $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = ccache compiling.debug $in
description = ccache compiling.release $in

rule cxx
rule mxx
command = /usr/bin/ccache /usr/bin/clang $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = ccache compiling.debug $in
description = ccache compiling.release $in

rule cc
rule cxx
command = /usr/bin/ccache /usr/bin/clang $ARGS -MMD -MF $out.d -o $out -c $in
deps = gcc
depfile = $out.d
description = ccache compiling.debug $in
description = ccache compiling.release $in


# rules for linker
rule ar
command = /usr/bin/ar $ARGS $out $in
description = archiving.debug $out
description = archiving.release $out

rule sh
rule ld
command = /usr/bin/clang++ -o $out $in $ARGS
description = linking.debug $out
description = linking.release $out

rule ld
rule sh
command = /usr/bin/clang++ -o $out $in $ARGS
description = linking.debug $out
description = linking.release $out


# build targets
Expand All @@ -61,60 +61,60 @@ build build.ninja: gen $
xmake.lua

# build target: bonding
build bonding: phony build/linux/x86_64/debug/bonding
build build/linux/x86_64/debug/bonding: ld build/.objs/bonding/linux/x86_64/debug/src/ipc.cpp.o build/.objs/bonding/linux/x86_64/debug/src/config.cpp.o build/.objs/bonding/linux/x86_64/debug/src/exec.cpp.o build/.objs/bonding/linux/x86_64/debug/src/hostname.cpp.o build/.objs/bonding/linux/x86_64/debug/src/main.cpp.o build/.objs/bonding/linux/x86_64/debug/src/capabilities.cpp.o build/.objs/bonding/linux/x86_64/debug/src/child.cpp.o build/.objs/bonding/linux/x86_64/debug/src/cli.cpp.o build/.objs/bonding/linux/x86_64/debug/src/configfile.cpp.o build/.objs/bonding/linux/x86_64/debug/src/container.cpp.o build/.objs/bonding/linux/x86_64/debug/src/environment.cpp.o build/.objs/bonding/linux/x86_64/debug/src/error.cpp.o build/.objs/bonding/linux/x86_64/debug/src/mount.cpp.o build/.objs/bonding/linux/x86_64/debug/src/namespace.cpp.o build/.objs/bonding/linux/x86_64/debug/src/resource.cpp.o build/.objs/bonding/linux/x86_64/debug/src/syscall.cpp.o build/.objs/bonding/linux/x86_64/debug/src/unix.cpp.o
ARGS = -m64 -L/usr/lib64 -lseccomp -lcap -lspdlog -lfmt -pthread
build bonding: phony build/linux/x86_64/release/bonding
build build/linux/x86_64/release/bonding: ld build/.objs/bonding/linux/x86_64/release/src/ipc.cpp.o build/.objs/bonding/linux/x86_64/release/src/config.cpp.o build/.objs/bonding/linux/x86_64/release/src/exec.cpp.o build/.objs/bonding/linux/x86_64/release/src/hostname.cpp.o build/.objs/bonding/linux/x86_64/release/src/main.cpp.o build/.objs/bonding/linux/x86_64/release/src/capabilities.cpp.o build/.objs/bonding/linux/x86_64/release/src/child.cpp.o build/.objs/bonding/linux/x86_64/release/src/cli.cpp.o build/.objs/bonding/linux/x86_64/release/src/configfile.cpp.o build/.objs/bonding/linux/x86_64/release/src/container.cpp.o build/.objs/bonding/linux/x86_64/release/src/environment.cpp.o build/.objs/bonding/linux/x86_64/release/src/error.cpp.o build/.objs/bonding/linux/x86_64/release/src/mount.cpp.o build/.objs/bonding/linux/x86_64/release/src/namespace.cpp.o build/.objs/bonding/linux/x86_64/release/src/syscall.cpp.o build/.objs/bonding/linux/x86_64/release/src/unix.cpp.o build/.objs/bonding/linux/x86_64/release/src/resource.cpp.o
ARGS = -m64 -L/usr/lib64 -s -lseccomp -lcap -lspdlog -lfmt -pthread

build build/.objs/bonding/linux/x86_64/debug/src/ipc.cpp.o: cxx src/ipc.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/ipc.cpp.o: cxx src/ipc.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/config.cpp.o: cxx src/config.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/config.cpp.o: cxx src/config.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/exec.cpp.o: cxx src/exec.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/exec.cpp.o: cxx src/exec.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/hostname.cpp.o: cxx src/hostname.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/hostname.cpp.o: cxx src/hostname.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/main.cpp.o: cxx src/main.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/main.cpp.o: cxx src/main.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/capabilities.cpp.o: cxx src/capabilities.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/capabilities.cpp.o: cxx src/capabilities.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/child.cpp.o: cxx src/child.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/child.cpp.o: cxx src/child.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/cli.cpp.o: cxx src/cli.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/cli.cpp.o: cxx src/cli.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/configfile.cpp.o: cxx src/configfile.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/configfile.cpp.o: cxx src/configfile.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/container.cpp.o: cxx src/container.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/container.cpp.o: cxx src/container.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/environment.cpp.o: cxx src/environment.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/environment.cpp.o: cxx src/environment.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/error.cpp.o: cxx src/error.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/error.cpp.o: cxx src/error.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/mount.cpp.o: cxx src/mount.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/mount.cpp.o: cxx src/mount.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/namespace.cpp.o: cxx src/namespace.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/namespace.cpp.o: cxx src/namespace.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/resource.cpp.o: cxx src/resource.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/syscall.cpp.o: cxx src/syscall.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/syscall.cpp.o: cxx src/syscall.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/unix.cpp.o: cxx src/unix.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build build/.objs/bonding/linux/x86_64/debug/src/unix.cpp.o: cxx src/unix.cpp
ARGS = -Qunused-arguments -m64 -g -O0 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include
build build/.objs/bonding/linux/x86_64/release/src/resource.cpp.o: cxx src/resource.cpp
ARGS = -Qunused-arguments -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -DSPDLOG_SHARED_LIB -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -isystem /home/xfri_public/.xmake/packages/n/nlohmann_json/v3.11.2/efd3cf16388a46048c8713952f1ede18/include -isystem -DNDEBUG

build default: phony bonding
build all: phony bonding
Expand Down
26 changes: 23 additions & 3 deletions src/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
#include "include/configfile.h"
#include "include/container.h"
#include "include/hostname.h"
#include "include/unix.h"
#include <cstdlib>
#include <error.h>
#include <iterator>
#include <spdlog/spdlog.h>
#include <string>
#include <vector>

namespace bonding::cli
Expand Down Expand Up @@ -248,14 +250,32 @@ namespace bonding::cli
Result<Void, error::Err>
run(const Parser & args) noexcept
{
return Ok(container::Container::start(configfile::Config_File::read("./bonding.json"))
.unwrap());
return container::Container::start(
configfile::Config_File::read("./bonding.json").unwrap());
}

Result<Void, error::Err>
init(const Parser & args) noexcept
{
return ERR_MSG(error::Code::Capabilities, "Not implemented");
std::string hostname;
std::string command;

std::cout << "Hostname: ";
std::getline(std::cin, hostname);

std::cout << "Command: ";
std::getline(std::cin, command);

unix::Filesystem::Mkdir("Bonding." + hostname).unwrap();
unix::Filesystem::Mkdir("Bonding." + hostname + "/mount_dir").unwrap();

unix::Filesystem::Write(
"Bonding." + hostname + "/bonding.json",
configfile::Config_File::generate_default(hostname, command).unwrap());

spdlog::info("Creating a Container...✓");

return Ok(Void());
}

Result<Void, error::Err>
Expand Down
Loading

0 comments on commit 29e61ab

Please sign in to comment.