A “dangerous” knifeman who used a Facebook message to try and rob a man outside York shops and stabbed him in his hand has been jailed.