2016-10-27 03:32:23 +00:00
# include <stdlib.h>
2016-10-27 01:14:07 +00:00
# include "init.h"
int get_init_command ( struct command * cmd ) {
// help text
cmd - > help_text . tagline = " Initializes IPFS config file. " ;
cmd - > help_text . short_description = " \n Initializes IPFS configuration files and generates a new keypair. \n \n ipfs uses a repository in the local file system. By default, the repo is \n located at ~/.ipfs. To change the repo location, set the $IPFS_PATH \n environment variable.: \n \n export IPFS_PATH=/path/to/ipfsrepo " ;
2016-10-27 03:32:23 +00:00
2016-10-27 01:14:07 +00:00
// arguments
// initialize an array of arguments with size of 1
2016-10-27 02:13:32 +00:00
cmd - > argument_count = 1 ;
2016-10-27 03:32:23 +00:00
// allocate memory for array of pointers
cmd - > arguments = malloc ( cmd - > argument_count * sizeof ( struct argument * ) ) ;
if ( cmd - > arguments = = NULL )
return 0 ;
// allocate memory for argument
cmd - > arguments [ 0 ] = malloc ( sizeof ( struct argument ) ) ;
int retVal = init_string_argument ( cmd - > arguments [ 0 ] , " default-config " , 0 , 0 , " Initialize with the given configuration " ) ;
cmd - > arguments [ 0 ] - > enable_stdin = 1 ;
2016-10-27 02:13:32 +00:00
return retVal ;
}
int uninit_command ( struct command * cmd ) {
for ( int i = 0 ; i < cmd - > argument_count ; i + + )
uninit_argument ( cmd - > arguments [ i ] ) ;
2016-10-27 03:32:23 +00:00
free ( cmd - > arguments ) ;
2016-10-27 01:14:07 +00:00
return 0 ;
}