func CreateCommand(store *wallet.Store) cli.Command {
	createExecutor := func(args []string) error {
		walletFile, err := wallet.ReadWallet()
		if err != nil {
			return err
		}
		ctx := sendContext{}

		switch len(args) {
		default:
			fallthrough
		case 4: // currency
			ctx.Currency = wallet.Currency(args[3])
			fallthrough
		case 3: // amount todo(arlyon) decimal numbers
			num, _ := strconv.Atoi(args[2])
			ctx.Amount.Value = int64(num)
			fallthrough
		case 2:
			if match, ok := walletFile.PrefixSearch(args[1]); ok {
				ctx.DstPublic = match
			} else if hexBytes, err := hex.DecodeString(args[1]); len(hexBytes) == ed25519.PublicKeySize && err == nil {
				ctx.DstPublic = hexBytes
			}
		case 1:
		case 0:
		}

		return createTransaction(*store, ctx, true)
	}

	createCompleter := func(in prompt.Document) []prompt.Suggest {
		suggestions := make([]prompt.Suggest, 0)

		walletFile, err := wallet.ReadWallet()
		if err != nil {
			return suggestions
		}
		currentCommand := in.TextBeforeCursor()
		args := strings.Split(currentCommand, " ")

		switch len(args) {
		case 2:
			// src
			for _, keyPair := range walletFile {
				suggestions = append(suggestions, prompt.Suggest{Text: hex.EncodeToString(keyPair.PublicKey)[:12]})
			}
		}

		return prompt.FilterFuzzy(suggestions, in.GetWordBeforeCursor(), true)
	}

	return cli.CreateCommand("create", "Create currency", createExecutor, createCompleter)
}
// CreateCommand creates the create command, allowing the user
// to create currency and deposit into the provided wallet
//
// syntax: create ${KEY} ${AMOUNT} ${CURRENCY}
CreateCommand creates the create command, allowing the user
to create currency and deposit into the provided wallet

create ${KEY} ${AMOUNT} ${CURRENCY}
// CreateCommand creates the create command allowing the user // to create currency and deposit into the provided wallet // // syntax : create $ { KEY } $ { AMOUNT } $ { CURRENCY }
func CreateCommand(store *wallet.Store) cli.Command {
	createExecutor := func(args []string) error {
		walletFile, err := wallet.ReadWallet()
		if err != nil {
			return err
		}
		ctx := sendContext{}
		switch len(args) {
		default:
			fallthrough
		case 4: 
			ctx.Currency = wallet.Currency(args[3])
			fallthrough
		case 3: 
			num, _ := strconv.Atoi(args[2])
			ctx.Amount.Value = int64(num)
			fallthrough
		case 2:
			if match, ok := walletFile.PrefixSearch(args[1]); ok {
				ctx.DstPublic = match
			} else if hexBytes, err := hex.DecodeString(args[1]); len(hexBytes) == ed25519.PublicKeySize && err == nil {
				ctx.DstPublic = hexBytes
			}
		case 1:
		case 0:
		}
		return createTransaction(*store, ctx, true)
	}
	createCompleter := func(in prompt.Document) []prompt.Suggest {
		suggestions := make([]prompt.Suggest, 0)
		walletFile, err := wallet.ReadWallet()
		if err != nil {
			return suggestions
		}
		currentCommand := in.TextBeforeCursor()
		args := strings.Split(currentCommand, " ")
		switch len(args) {
		case 2:
			for _, keyPair := range walletFile {
				suggestions = append(suggestions, prompt.Suggest{Text: hex.EncodeToString(keyPair.PublicKey)[:12]})
			}
		}
		return prompt.FilterFuzzy(suggestions, in.GetWordBeforeCursor(), true)
	}
	return cli.CreateCommand("create", "Create currency", createExecutor, createCompleter)
}
func CreateCommand ( store * wallet . Store ) cli . Command { createExecutor := func ( args [ ] string ) error { walletFile , err := wallet . ReadWallet ( ) if err != nil { return err } ctx := sendContext { } switch len ( args ) { default : fallthrough case 4 : ctx . Currency = wallet . Currency ( args [ 3 ] ) fallthrough case 3 : num , _ := strconv . Atoi ( args [ 2 ] ) ctx . Amount . Value = int64 ( num ) fallthrough case 2 : if match , ok := walletFile . PrefixSearch ( args [ 1 ] ) ; ok { ctx . DstPublic = match } else if hexBytes , err := hex . DecodeString ( args [ 1 ] ) ; len ( hexBytes ) == ed25519 . PublicKeySize && err == nil { ctx . DstPublic = hexBytes } case 1 : case 0 : } return createTransaction ( * store , ctx , true ) } createCompleter := func ( in prompt . Document ) [ ] prompt . Suggest { suggestions := make ( [ ] prompt . Suggest , 0 ) walletFile , err := wallet . ReadWallet ( ) if err != nil { return suggestions } currentCommand := in . TextBeforeCursor ( ) args := strings . Split ( currentCommand , " " ) switch len ( args ) { case 2 : for _ , keyPair := range walletFile { suggestions = append ( suggestions , prompt . Suggest { Text : hex . EncodeToString ( keyPair . PublicKey ) [ : 12 ] } ) } } return prompt . FilterFuzzy ( suggestions , in . GetWordBeforeCursor ( ) , true ) } return cli . CreateCommand ( " " , " " , createExecutor , createCompleter ) }
CreateCommand creates the create command, allowing the user
to create currency and deposit into the provided wallet
CreateCommand creates the create command allowing the user to create currency and deposit into the provided wallet
// currency // amount todo(arlyon) decimal numbers // src