How do I remove All and Published if not admin?

Is it possible to Remove those menu items for a Post and a Custom Post Type page ?
thank you

enter image description here

add_filter( 'views_edit-post', function( $views )
    if( current_user_can( 'manage_options' ) )
        return $views;

    $remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ];

foreach( (array) $remove_views as $view )
    if( isset( $views[$view] ) )
        unset( $views[$view] );
return $views;
} );

 * Force the 'mine' view on the 'edit-post' screen
add_action( 'pre_get_posts', function( \WP_Query $q )
        && $q->is_main_query() 
        && 'edit-post' === get_current_screen()->id 
        && ! current_user_can( 'manage_options' )
        $q->set( 'author', get_current_user_id() ); 
} );'

This code comes from this answer.

This is working great for posts. But I can’t wrap my head around using it for a custom post type.

Solutions Collecting From Web of "How do I remove All and Published if not admin?"

responding to code added by OP

replace post with the slug of your post type.

add_filter('views_edit-SLUG_OF_YOUR_POST_TYPE', function($views) { ...

So a custom post type of Library Books with a slug of library-books:

add_filter('views_edit-library-books', function($views) {...

original response

Use $wp_roles->remove_cap( $role, $cap ); on all roles except the admin, removing the edit_others_posts cap.
See this for caps and roles.