4343#include "src/common/libutil/jpath.h"
4444#include "src/common/libjob/job.h"
4545#include "src/common/libjob/unwrap.h"
46+ #include "src/common/libjob/idf58.h"
4647#include "src/common/libutil/read_all.h"
4748#include "src/common/libutil/monotime.h"
4849#include "src/common/libutil/fsd.h"
@@ -1462,11 +1463,7 @@ size_t read_jobspec (const char *name, void **bufp)
14621463
14631464static void print_jobid (flux_jobid_t id )
14641465{
1465- char buf [32 ];
1466- if (flux_job_id_encode (id , "f58" , buf , sizeof (buf )) < 0 )
1467- printf ("%ju\n" , (uintmax_t ) id );
1468- else
1469- printf ("%s\n" , buf );
1466+ printf ("%s\n" , idf58 (id ));
14701467}
14711468
14721469int cmd_submit (optparse_t * p , int argc , char * * argv )
@@ -3286,6 +3283,7 @@ void info_usage (void)
32863283}
32873284
32883285struct info_ctx {
3286+ const char * id_arg ;
32893287 flux_jobid_t id ;
32903288 json_t * keys ;
32913289 bool original ;
@@ -3298,7 +3296,7 @@ void info_output (flux_future_t *f, const char *suffix, struct info_ctx *ctx)
32983296 if (flux_rpc_get_unpack (f , "{s:s}" , suffix , & s ) < 0 ) {
32993297 if (errno == ENOENT ) {
33003298 flux_future_destroy (f );
3301- log_msg_exit ("job %ju id or key not found" , ( uintmax_t ) ctx -> id );
3299+ log_msg_exit ("job %s id or key not found" , ctx -> id_arg );
33023300 }
33033301 else
33043302 log_err_exit ("flux_rpc_get_unpack" );
@@ -3343,6 +3341,7 @@ void info_lookup (flux_t *h,
33433341 flux_future_t * f ;
33443342 struct info_ctx ctx = {0 };
33453343
3344+ ctx .id_arg = argv [optindex - 1 ];
33463345 ctx .id = id ;
33473346 if (!(ctx .keys = json_array ()))
33483347 log_msg_exit ("json_array" );
@@ -3426,13 +3425,6 @@ int cmd_stats (optparse_t *p, int argc, char **argv)
34263425 return (0 );
34273426}
34283427
3429- static char * to_f58 (flux_jobid_t id , char * buf , int len )
3430- {
3431- if (flux_job_id_encode (id , "f58" , buf , len ) < 0 )
3432- (void ) snprintf (buf , len , "%ju" , (uintmax_t ) id );
3433- return buf ;
3434- }
3435-
34363428int cmd_wait (optparse_t * p , int argc , char * * argv )
34373429{
34383430 flux_t * h ;
@@ -3441,7 +3433,6 @@ int cmd_wait (optparse_t *p, int argc, char **argv)
34413433 flux_jobid_t id = FLUX_JOBID_ANY ;
34423434 bool success ;
34433435 const char * errstr ;
3444- char buf [32 ];
34453436 int rc = 0 ;
34463437
34473438 if ((argc - optindex ) > 1 ) {
@@ -3472,16 +3463,14 @@ int cmd_wait (optparse_t *p, int argc, char **argv)
34723463 log_msg_exit ("flux_job_wait_get_id: %s" ,
34733464 future_strerror (f , errno ));
34743465 if (!success ) {
3475- fprintf (stderr , "%s: %s\n" ,
3476- to_f58 (id , buf , sizeof (buf )),
3477- errstr );
3466+ fprintf (stderr , "%s: %s\n" , idf58 (id ), errstr );
34783467 rc = 1 ;
34793468 }
34803469 else {
34813470 if (optparse_hasopt (p , "verbose" ))
34823471 fprintf (stderr ,
34833472 "%s: job completed successfully\n" ,
3484- to_f58 (id , buf , sizeof ( buf ) ));
3473+ idf58 (id ));
34853474 }
34863475 flux_future_destroy (f );
34873476 }
@@ -3502,7 +3491,7 @@ int cmd_wait (optparse_t *p, int argc, char **argv)
35023491 if (id == FLUX_JOBID_ANY ) {
35033492 if (flux_job_wait_get_id (f , & id ) < 0 )
35043493 log_err_exit ("flux_job_wait_get_id" );
3505- printf ("%s\n" , to_f58 (id , buf , sizeof ( buf ) ));
3494+ printf ("%s\n" , idf58 (id ));
35063495 }
35073496 if (!success )
35083497 log_msg_exit ("%s" , errstr );
@@ -3902,7 +3891,6 @@ int cmd_last (optparse_t *p, int argc, char **argv)
39023891 int optindex = optparse_option_index (p );
39033892 flux_future_t * f ;
39043893 flux_t * h ;
3905- char buf [32 ];
39063894 json_t * jobs ;
39073895 size_t index ;
39083896 json_t * entry ;
@@ -3941,12 +3929,8 @@ int cmd_last (optparse_t *p, int argc, char **argv)
39413929 }
39423930 if (json_array_size (jobs ) == 0 )
39433931 log_msg_exit ("job history is empty" );
3944- json_array_foreach (jobs , index , entry ) {
3945- flux_jobid_t id = json_integer_value (entry );
3946- if (flux_job_id_encode (id , "f58" , buf , sizeof (buf )) < 0 )
3947- log_err_exit ("error encoding job ID" );
3948- printf ("%s\n" , buf );
3949- }
3932+ json_array_foreach (jobs , index , entry )
3933+ printf ("%s\n" , idf58 (json_integer_value (entry )));
39503934 flux_future_destroy (f );
39513935 flux_close (h );
39523936 return 0 ;
0 commit comments